<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">{-
(c) The University of Glasgow 2006
(c) The GRASP/AQUA Project, Glasgow University, 1998
Type and Coercion - friends' interface
-}</span><span>
</span><span id="line-6"></span><span>
</span><span id="line-7"></span><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span>
</span><span id="line-8"></span><span class="hs-pragma">{-# LANGUAGE BangPatterns #-}</span><span>
</span><span id="line-9"></span><span class="hs-pragma">{-# OPTIONS_GHC -Wno-incomplete-record-updates #-}</span><span>
</span><span id="line-10"></span><span>
</span><span id="line-11"></span><span class="hs-comment">-- | Substitution into types and coercions.</span><span>
</span><span id="line-12"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Core.TyCo.Subst</span><span>
</span><span id="line-13"></span><span>  </span><span class="hs-special">(</span><span>
</span><span id="line-14"></span><span>        </span><span class="annot"><span class="hs-comment">-- * Substitutions</span></span><span>
</span><span id="line-15"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier">TCvSubst</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TvSubstEnv"><span class="hs-identifier">TvSubstEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#CvSubstEnv"><span class="hs-identifier">CvSubstEnv</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-16"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#emptyTvSubstEnv"><span class="hs-identifier">emptyTvSubstEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#emptyCvSubstEnv"><span class="hs-identifier">emptyCvSubstEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#composeTCvSubstEnv"><span class="hs-identifier">composeTCvSubstEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#composeTCvSubst"><span class="hs-identifier">composeTCvSubst</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-17"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#emptyTCvSubst"><span class="hs-identifier">emptyTCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#mkEmptyTCvSubst"><span class="hs-identifier">mkEmptyTCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#isEmptyTCvSubst"><span class="hs-identifier">isEmptyTCvSubst</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-18"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#mkTCvSubst"><span class="hs-identifier">mkTCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#mkTvSubst"><span class="hs-identifier">mkTvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#mkCvSubst"><span class="hs-identifier">mkCvSubst</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-19"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#getTvSubstEnv"><span class="hs-identifier">getTvSubstEnv</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-20"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#getCvSubstEnv"><span class="hs-identifier">getCvSubstEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#getTCvInScope"><span class="hs-identifier">getTCvInScope</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#getTCvSubstRangeFVs"><span class="hs-identifier">getTCvSubstRangeFVs</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-21"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#isInScope"><span class="hs-identifier">isInScope</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#notElemTCvSubst"><span class="hs-identifier">notElemTCvSubst</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-22"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#setTvSubstEnv"><span class="hs-identifier">setTvSubstEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#setCvSubstEnv"><span class="hs-identifier">setCvSubstEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#zapTCvSubst"><span class="hs-identifier">zapTCvSubst</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-23"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#extendTCvInScope"><span class="hs-identifier">extendTCvInScope</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#extendTCvInScopeList"><span class="hs-identifier">extendTCvInScopeList</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#extendTCvInScopeSet"><span class="hs-identifier">extendTCvInScopeSet</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-24"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#extendTCvSubst"><span class="hs-identifier">extendTCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#extendTCvSubstWithClone"><span class="hs-identifier">extendTCvSubstWithClone</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-25"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#extendCvSubst"><span class="hs-identifier">extendCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#extendCvSubstWithClone"><span class="hs-identifier">extendCvSubstWithClone</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-26"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#extendTvSubst"><span class="hs-identifier">extendTvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#extendTvSubstBinderAndInScope"><span class="hs-identifier">extendTvSubstBinderAndInScope</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#extendTvSubstWithClone"><span class="hs-identifier">extendTvSubstWithClone</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-27"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#extendTvSubstList"><span class="hs-identifier">extendTvSubstList</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#extendTvSubstAndInScope"><span class="hs-identifier">extendTvSubstAndInScope</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-28"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#extendTCvSubstList"><span class="hs-identifier">extendTCvSubstList</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-29"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#unionTCvSubst"><span class="hs-identifier">unionTCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#zipTyEnv"><span class="hs-identifier">zipTyEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#zipCoEnv"><span class="hs-identifier">zipCoEnv</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-30"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#zipTvSubst"><span class="hs-identifier">zipTvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#zipCvSubst"><span class="hs-identifier">zipCvSubst</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-31"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#zipTCvSubst"><span class="hs-identifier">zipTCvSubst</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-32"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#mkTvSubstPrs"><span class="hs-identifier">mkTvSubstPrs</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-33"></span><span>
</span><span id="line-34"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTyWith"><span class="hs-identifier">substTyWith</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTyWithCoVars"><span class="hs-identifier">substTyWithCoVars</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTysWith"><span class="hs-identifier">substTysWith</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTysWithCoVars"><span class="hs-identifier">substTysWithCoVars</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-35"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substCoWith"><span class="hs-identifier">substCoWith</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-36"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTy"><span class="hs-identifier">substTy</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTyAddInScope"><span class="hs-identifier">substTyAddInScope</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substScaledTy"><span class="hs-identifier">substScaledTy</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-37"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTyUnchecked"><span class="hs-identifier">substTyUnchecked</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTysUnchecked"><span class="hs-identifier">substTysUnchecked</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substScaledTysUnchecked"><span class="hs-identifier">substScaledTysUnchecked</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substThetaUnchecked"><span class="hs-identifier">substThetaUnchecked</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-38"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTyWithUnchecked"><span class="hs-identifier">substTyWithUnchecked</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substScaledTyUnchecked"><span class="hs-identifier">substScaledTyUnchecked</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-39"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substCoUnchecked"><span class="hs-identifier">substCoUnchecked</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substCoWithUnchecked"><span class="hs-identifier">substCoWithUnchecked</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-40"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTyWithInScope"><span class="hs-identifier">substTyWithInScope</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-41"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTys"><span class="hs-identifier">substTys</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substScaledTys"><span class="hs-identifier">substScaledTys</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTheta"><span class="hs-identifier">substTheta</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-42"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#lookupTyVar"><span class="hs-identifier">lookupTyVar</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-43"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substCo"><span class="hs-identifier">substCo</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substCos"><span class="hs-identifier">substCos</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substCoVar"><span class="hs-identifier">substCoVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substCoVars"><span class="hs-identifier">substCoVars</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#lookupCoVar"><span class="hs-identifier">lookupCoVar</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-44"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#cloneTyVarBndr"><span class="hs-identifier">cloneTyVarBndr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#cloneTyVarBndrs"><span class="hs-identifier">cloneTyVarBndrs</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-45"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substVarBndr"><span class="hs-identifier">substVarBndr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substVarBndrs"><span class="hs-identifier">substVarBndrs</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-46"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTyVarBndr"><span class="hs-identifier">substTyVarBndr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTyVarBndrs"><span class="hs-identifier">substTyVarBndrs</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-47"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substCoVarBndr"><span class="hs-identifier">substCoVarBndr</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-48"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTyVar"><span class="hs-identifier">substTyVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTyVars"><span class="hs-identifier">substTyVars</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTyCoVars"><span class="hs-identifier">substTyCoVars</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-49"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substForAllCoBndr"><span class="hs-identifier">substForAllCoBndr</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-50"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substVarBndrUsing"><span class="hs-identifier">substVarBndrUsing</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substForAllCoBndrUsing"><span class="hs-identifier">substForAllCoBndrUsing</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-51"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#checkValidSubst"><span class="hs-identifier">checkValidSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#isValidTCvSubst"><span class="hs-identifier">isValidTCvSubst</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-52"></span><span>  </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span class="hs-cpp">

#include &quot;HsVersions.h&quot;
</span><span>
</span><span id="line-56"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-57"></span><span>
</span><span id="line-58"></span><span class="hs-keyword">import</span><span> </span><span class="hs-pragma">{-# SOURCE</span><span> </span><span class="hs-pragma">#-}</span><span> </span><span class="annot"><a href="GHC.Core.Type.html"><span class="hs-identifier">GHC.Core.Type</span></a></span><span>
</span><span id="line-59"></span><span>   </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.Type.html#mkCastTy"><span class="hs-identifier">mkCastTy</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Type.html#mkAppTy"><span class="hs-identifier">mkAppTy</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Type.html#isCoercionTy"><span class="hs-identifier">isCoercionTy</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-60"></span><span class="hs-keyword">import</span><span> </span><span class="hs-pragma">{-# SOURCE</span><span> </span><span class="hs-pragma">#-}</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html"><span class="hs-identifier">GHC.Core.Coercion</span></a></span><span>
</span><span id="line-61"></span><span>   </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html#mkCoVarCo"><span class="hs-identifier">mkCoVarCo</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html#mkKindCo"><span class="hs-identifier">mkKindCo</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html#mkNthCo"><span class="hs-identifier">mkNthCo</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html#mkTransCo"><span class="hs-identifier">mkTransCo</span></a></span><span>
</span><span id="line-62"></span><span>   </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html#mkNomReflCo"><span class="hs-identifier">mkNomReflCo</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html#mkSubCo"><span class="hs-identifier">mkSubCo</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html#mkSymCo"><span class="hs-identifier">mkSymCo</span></a></span><span>
</span><span id="line-63"></span><span>   </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html#mkFunCo"><span class="hs-identifier">mkFunCo</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html#mkForAllCo"><span class="hs-identifier">mkForAllCo</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html#mkUnivCo"><span class="hs-identifier">mkUnivCo</span></a></span><span>
</span><span id="line-64"></span><span>   </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html#mkAxiomInstCo"><span class="hs-identifier">mkAxiomInstCo</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html#mkAppCo"><span class="hs-identifier">mkAppCo</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html#mkGReflCo"><span class="hs-identifier">mkGReflCo</span></a></span><span>
</span><span id="line-65"></span><span>   </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html#mkInstCo"><span class="hs-identifier">mkInstCo</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html#mkLRCo"><span class="hs-identifier">mkLRCo</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html#mkTyConAppCo"><span class="hs-identifier">mkTyConAppCo</span></a></span><span>
</span><span id="line-66"></span><span>   </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html#mkCoercionType"><span class="hs-identifier">mkCoercionType</span></a></span><span>
</span><span id="line-67"></span><span>   </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html#coercionKind"><span class="hs-identifier">coercionKind</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html#coercionLKind"><span class="hs-identifier">coercionLKind</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html#coVarKindsTypesRole"><span class="hs-identifier">coVarKindsTypesRole</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-68"></span><span class="hs-keyword">import</span><span> </span><span class="hs-pragma">{-# SOURCE</span><span> </span><span class="hs-pragma">#-}</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Ppr.html"><span class="hs-identifier">GHC.Core.TyCo.Ppr</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Ppr.html#pprTyVar"><span class="hs-identifier">pprTyVar</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-69"></span><span>
</span><span id="line-70"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html"><span class="hs-identifier">GHC.Core.TyCo.Rep</span></a></span><span>
</span><span id="line-71"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.FVs.html"><span class="hs-identifier">GHC.Core.TyCo.FVs</span></a></span><span>
</span><span id="line-72"></span><span>
</span><span id="line-73"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.html"><span class="hs-identifier">GHC.Types.Var</span></a></span><span>
</span><span id="line-74"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html"><span class="hs-identifier">GHC.Types.Var.Set</span></a></span><span>
</span><span id="line-75"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html"><span class="hs-identifier">GHC.Types.Var.Env</span></a></span><span>
</span><span id="line-76"></span><span>
</span><span id="line-77"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.Pair.html"><span class="hs-identifier">GHC.Data.Pair</span></a></span><span>
</span><span id="line-78"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html"><span class="hs-identifier">GHC.Utils.Misc</span></a></span><span>
</span><span id="line-79"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Supply.html"><span class="hs-identifier">GHC.Types.Unique.Supply</span></a></span><span>
</span><span id="line-80"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Unique.html"><span class="hs-identifier">GHC.Types.Unique</span></a></span><span>
</span><span id="line-81"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Unique.FM.html"><span class="hs-identifier">GHC.Types.Unique.FM</span></a></span><span>
</span><span id="line-82"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Set.html"><span class="hs-identifier">GHC.Types.Unique.Set</span></a></span><span>
</span><span id="line-83"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html"><span class="hs-identifier">GHC.Utils.Outputable</span></a></span><span>
</span><span id="line-84"></span><span>
</span><span id="line-85"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.List.html#"><span class="hs-identifier">Data.List</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Traversable.html#mapAccumL"><span class="hs-identifier">mapAccumL</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-86"></span><span>
</span><span id="line-87"></span><span class="hs-comment">{-
%************************************************************************
%*                                                                      *
                        Substitutions
      Data type defined here to avoid unnecessary mutual recursion
%*                                                                      *
%************************************************************************
-}</span><span>
</span><span id="line-95"></span><span>
</span><span id="line-96"></span><span class="hs-comment">-- | Type &amp; coercion substitution</span><span>
</span><span id="line-97"></span><span class="hs-comment">--</span><span>
</span><span id="line-98"></span><span class="hs-comment">-- #tcvsubst_invariant#</span><span>
</span><span id="line-99"></span><span class="hs-comment">-- The following invariants must hold of a 'TCvSubst':</span><span>
</span><span id="line-100"></span><span class="hs-comment">--</span><span>
</span><span id="line-101"></span><span class="hs-comment">-- 1. The in-scope set is needed /only/ to</span><span>
</span><span id="line-102"></span><span class="hs-comment">-- guide the generation of fresh uniques</span><span>
</span><span id="line-103"></span><span class="hs-comment">--</span><span>
</span><span id="line-104"></span><span class="hs-comment">-- 2. In particular, the /kind/ of the type variables in</span><span>
</span><span id="line-105"></span><span class="hs-comment">-- the in-scope set is not relevant</span><span>
</span><span id="line-106"></span><span class="hs-comment">--</span><span>
</span><span id="line-107"></span><span class="hs-comment">-- 3. The substitution is only applied ONCE! This is because</span><span>
</span><span id="line-108"></span><span class="hs-comment">-- in general such application will not reach a fixed point.</span><span>
</span><span id="line-109"></span><span class="hs-keyword">data</span><span> </span><span id="TCvSubst"><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-var">TCvSubst</span></a></span></span><span>
</span><span id="line-110"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="TCvSubst"><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-var">TCvSubst</span></a></span></span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#InScopeSet"><span class="hs-identifier hs-type">InScopeSet</span></a></span><span> </span><span class="hs-comment">-- The in-scope type and kind variables</span><span>
</span><span id="line-111"></span><span>             </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TvSubstEnv"><span class="hs-identifier hs-type">TvSubstEnv</span></a></span><span> </span><span class="hs-comment">-- Substitutes both type and kind variables</span><span>
</span><span id="line-112"></span><span>             </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#CvSubstEnv"><span class="hs-identifier hs-type">CvSubstEnv</span></a></span><span> </span><span class="hs-comment">-- Substitutes coercion variables</span><span>
</span><span id="line-113"></span><span>        </span><span class="hs-comment">-- See Note [Substitutions apply only once]</span><span>
</span><span id="line-114"></span><span>        </span><span class="hs-comment">-- and Note [Extending the TvSubstEnv]</span><span>
</span><span id="line-115"></span><span>        </span><span class="hs-comment">-- and Note [Substituting types and coercions]</span><span>
</span><span id="line-116"></span><span>        </span><span class="hs-comment">-- and Note [The substitution invariant]</span><span>
</span><span id="line-117"></span><span>
</span><span id="line-118"></span><span class="hs-comment">-- | A substitution of 'Type's for 'TyVar's</span><span>
</span><span id="line-119"></span><span class="hs-comment">--                 and 'Kind's for 'KindVar's</span><span>
</span><span id="line-120"></span><span class="hs-keyword">type</span><span> </span><span id="TvSubstEnv"><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TvSubstEnv"><span class="hs-identifier hs-var">TvSubstEnv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#TyVarEnv"><span class="hs-identifier hs-type">TyVarEnv</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-121"></span><span>  </span><span class="hs-comment">-- NB: A TvSubstEnv is used</span><span>
</span><span id="line-122"></span><span>  </span><span class="hs-comment">--   both inside a TCvSubst (with the apply-once invariant</span><span>
</span><span id="line-123"></span><span>  </span><span class="hs-comment">--        discussed in Note [Substitutions apply only once],</span><span>
</span><span id="line-124"></span><span>  </span><span class="hs-comment">--   and  also independently in the middle of matching,</span><span>
</span><span id="line-125"></span><span>  </span><span class="hs-comment">--        and unification (see Types.Unify).</span><span>
</span><span id="line-126"></span><span>  </span><span class="hs-comment">-- So you have to look at the context to know if it's idempotent or</span><span>
</span><span id="line-127"></span><span>  </span><span class="hs-comment">-- apply-once or whatever</span><span>
</span><span id="line-128"></span><span>
</span><span id="line-129"></span><span class="hs-comment">-- | A substitution of 'Coercion's for 'CoVar's</span><span>
</span><span id="line-130"></span><span class="hs-keyword">type</span><span> </span><span id="CvSubstEnv"><span class="annot"><a href="GHC.Core.TyCo.Subst.html#CvSubstEnv"><span class="hs-identifier hs-var">CvSubstEnv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#CoVarEnv"><span class="hs-identifier hs-type">CoVarEnv</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span>
</span><span id="line-131"></span><span>
</span><span id="line-132"></span><span class="hs-comment">{- Note [The substitution invariant]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When calling (substTy subst ty) it should be the case that
the in-scope set in the substitution is a superset of both:

  (SIa) The free vars of the range of the substitution
  (SIb) The free vars of ty minus the domain of the substitution

The same rules apply to other substitutions (notably GHC.Core.Subst.Subst)

* Reason for (SIa). Consider
      substTy [a :-&gt; Maybe b] (forall b. b-&gt;a)
  we must rename the forall b, to get
      forall b2. b2 -&gt; Maybe b
  Making 'b' part of the in-scope set forces this renaming to
  take place.

* Reason for (SIb). Consider
     substTy [a :-&gt; Maybe b] (forall b. (a,b,x))
  Then if we use the in-scope set {b}, satisfying (SIa), there is
  a danger we will rename the forall'd variable to 'x' by mistake,
  getting this:
      forall x. (Maybe b, x, x)
  Breaking (SIb) caused the bug from #11371.

Note: if the free vars of the range of the substitution are freshly created,
then the problems of (SIa) can't happen, and so it would be sound to
ignore (SIa).

Note [Substitutions apply only once]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We use TCvSubsts to instantiate things, and we might instantiate
        forall a b. ty
with the types
        [a, b], or [b, a].
So the substitution might go [a-&gt;b, b-&gt;a].  A similar situation arises in Core
when we find a beta redex like
        (/\ a /\ b -&gt; e) b a
Then we also end up with a substitution that permutes type variables. Other
variations happen to; for example [a -&gt; (a, b)].

        ********************************************************
        *** So a substitution must be applied precisely once ***
        ********************************************************

A TCvSubst is not idempotent, but, unlike the non-idempotent substitution
we use during unifications, it must not be repeatedly applied.

Note [Extending the TvSubstEnv]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
See #tcvsubst_invariant# for the invariants that must hold.

This invariant allows a short-cut when the subst envs are empty:
if the TvSubstEnv and CvSubstEnv are empty --- i.e. (isEmptyTCvSubst subst)
holds --- then (substTy subst ty) does nothing.

For example, consider:
        (/\a. /\b:(a~Int). ...b..) Int
We substitute Int for 'a'.  The Unique of 'b' does not change, but
nevertheless we add 'b' to the TvSubstEnv, because b's kind does change

This invariant has several crucial consequences:

* In substVarBndr, we need extend the TvSubstEnv
        - if the unique has changed
        - or if the kind has changed

* In substTyVar, we do not need to consult the in-scope set;
  the TvSubstEnv is enough

* In substTy, substTheta, we can short-circuit when the TvSubstEnv is empty

Note [Substituting types and coercions]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Types and coercions are mutually recursive, and either may have variables
&quot;belonging&quot; to the other. Thus, every time we wish to substitute in a
type, we may also need to substitute in a coercion, and vice versa.
However, the constructor used to create type variables is distinct from
that of coercion variables, so we carry two VarEnvs in a TCvSubst. Note
that it would be possible to use the CoercionTy constructor to combine
these environments, but that seems like a false economy.

Note that the TvSubstEnv should *never* map a CoVar (built with the Id
constructor) and the CvSubstEnv should *never* map a TyVar. Furthermore,
the range of the TvSubstEnv should *never* include a type headed with
CoercionTy.
-}</span><span>
</span><span id="line-219"></span><span>
</span><span id="line-220"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#emptyTvSubstEnv"><span class="hs-identifier hs-type">emptyTvSubstEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TvSubstEnv"><span class="hs-identifier hs-type">TvSubstEnv</span></a></span><span>
</span><span id="line-221"></span><span id="emptyTvSubstEnv"><span class="annot"><span class="annottext">emptyTvSubstEnv :: TvSubstEnv
</span><a href="GHC.Core.TyCo.Subst.html#emptyTvSubstEnv"><span class="hs-identifier hs-var hs-var">emptyTvSubstEnv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
forall a. VarEnv a
</span><a href="GHC.Types.Var.Env.html#emptyVarEnv"><span class="hs-identifier hs-var">emptyVarEnv</span></a></span><span>
</span><span id="line-222"></span><span>
</span><span id="line-223"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#emptyCvSubstEnv"><span class="hs-identifier hs-type">emptyCvSubstEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#CvSubstEnv"><span class="hs-identifier hs-type">CvSubstEnv</span></a></span><span>
</span><span id="line-224"></span><span id="emptyCvSubstEnv"><span class="annot"><span class="annottext">emptyCvSubstEnv :: CvSubstEnv
</span><a href="GHC.Core.TyCo.Subst.html#emptyCvSubstEnv"><span class="hs-identifier hs-var hs-var">emptyCvSubstEnv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
forall a. VarEnv a
</span><a href="GHC.Types.Var.Env.html#emptyVarEnv"><span class="hs-identifier hs-var">emptyVarEnv</span></a></span><span>
</span><span id="line-225"></span><span>
</span><span id="line-226"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#composeTCvSubstEnv"><span class="hs-identifier hs-type">composeTCvSubstEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#InScopeSet"><span class="hs-identifier hs-type">InScopeSet</span></a></span><span>
</span><span id="line-227"></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TvSubstEnv"><span class="hs-identifier hs-type">TvSubstEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#CvSubstEnv"><span class="hs-identifier hs-type">CvSubstEnv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-228"></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TvSubstEnv"><span class="hs-identifier hs-type">TvSubstEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#CvSubstEnv"><span class="hs-identifier hs-type">CvSubstEnv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-229"></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TvSubstEnv"><span class="hs-identifier hs-type">TvSubstEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#CvSubstEnv"><span class="hs-identifier hs-type">CvSubstEnv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-230"></span><span class="hs-comment">-- ^ @(compose env1 env2)(x)@ is @env1(env2(x))@; i.e. apply @env2@ then @env1@.</span><span>
</span><span id="line-231"></span><span class="hs-comment">-- It assumes that both are idempotent.</span><span>
</span><span id="line-232"></span><span class="hs-comment">-- Typically, @env1@ is the refinement to a base substitution @env2@</span><span>
</span><span id="line-233"></span><span id="composeTCvSubstEnv"><span class="annot"><span class="annottext">composeTCvSubstEnv :: InScopeSet
-&gt; (TvSubstEnv, CvSubstEnv)
-&gt; (TvSubstEnv, CvSubstEnv)
-&gt; (TvSubstEnv, CvSubstEnv)
</span><a href="GHC.Core.TyCo.Subst.html#composeTCvSubstEnv"><span class="hs-identifier hs-var hs-var">composeTCvSubstEnv</span></a></span></span><span> </span><span id="local-6989586621680855232"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855232"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680855231"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855231"><span class="hs-identifier hs-var">tenv1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680855230"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855230"><span class="hs-identifier hs-var">cenv1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680855229"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855229"><span class="hs-identifier hs-var">tenv2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680855228"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855228"><span class="hs-identifier hs-var">cenv2</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-234"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855231"><span class="hs-identifier hs-var">tenv1</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv -&gt; TvSubstEnv -&gt; TvSubstEnv
forall a. VarEnv a -&gt; VarEnv a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#plusVarEnv"><span class="hs-operator hs-var">`plusVarEnv`</span></a></span><span> </span><span class="annot"><span class="annottext">(Type -&gt; Type) -&gt; TvSubstEnv -&gt; TvSubstEnv
forall a b. (a -&gt; b) -&gt; VarEnv a -&gt; VarEnv b
</span><a href="GHC.Types.Var.Env.html#mapVarEnv"><span class="hs-identifier hs-var">mapVarEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; Type -&gt; Type
TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTy"><span class="hs-identifier hs-var">substTy</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680855225"><span class="hs-identifier hs-var">subst1</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855229"><span class="hs-identifier hs-var">tenv2</span></a></span><span>
</span><span id="line-235"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855230"><span class="hs-identifier hs-var">cenv1</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv -&gt; CvSubstEnv -&gt; CvSubstEnv
forall a. VarEnv a -&gt; VarEnv a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#plusVarEnv"><span class="hs-operator hs-var">`plusVarEnv`</span></a></span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; Coercion) -&gt; CvSubstEnv -&gt; CvSubstEnv
forall a b. (a -&gt; b) -&gt; VarEnv a -&gt; VarEnv b
</span><a href="GHC.Types.Var.Env.html#mapVarEnv"><span class="hs-identifier hs-var">mapVarEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; Coercion -&gt; Coercion
TCvSubst -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.TyCo.Subst.html#substCo"><span class="hs-identifier hs-var">substCo</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680855225"><span class="hs-identifier hs-var">subst1</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855228"><span class="hs-identifier hs-var">cenv2</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-236"></span><span>        </span><span class="hs-comment">-- First apply env1 to the range of env2</span><span>
</span><span id="line-237"></span><span>        </span><span class="hs-comment">-- Then combine the two, making sure that env1 loses if</span><span>
</span><span id="line-238"></span><span>        </span><span class="hs-comment">-- both bind the same variable; that's why env1 is the</span><span>
</span><span id="line-239"></span><span>        </span><span class="hs-comment">--  *left* argument to plusVarEnv, because the right arg wins</span><span>
</span><span id="line-240"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-241"></span><span>    </span><span id="local-6989586621680855225"><span class="annot"><span class="annottext">subst1 :: TCvSubst
</span><a href="#local-6989586621680855225"><span class="hs-identifier hs-var hs-var">subst1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-var">TCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855232"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855231"><span class="hs-identifier hs-var">tenv1</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855230"><span class="hs-identifier hs-var">cenv1</span></a></span><span>
</span><span id="line-242"></span><span>
</span><span id="line-243"></span><span class="hs-comment">-- | Composes two substitutions, applying the second one provided first,</span><span>
</span><span id="line-244"></span><span class="hs-comment">-- like in function composition.</span><span>
</span><span id="line-245"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#composeTCvSubst"><span class="hs-identifier hs-type">composeTCvSubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-246"></span><span id="composeTCvSubst"><span class="annot"><span class="annottext">composeTCvSubst :: TCvSubst -&gt; TCvSubst -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#composeTCvSubst"><span class="hs-identifier hs-var hs-var">composeTCvSubst</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span id="local-6989586621680855224"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855224"><span class="hs-identifier hs-var">is1</span></a></span></span><span> </span><span id="local-6989586621680855223"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855223"><span class="hs-identifier hs-var">tenv1</span></a></span></span><span> </span><span id="local-6989586621680855222"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855222"><span class="hs-identifier hs-var">cenv1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span id="local-6989586621680855221"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855221"><span class="hs-identifier hs-var">is2</span></a></span></span><span> </span><span id="local-6989586621680855220"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855220"><span class="hs-identifier hs-var">tenv2</span></a></span></span><span> </span><span id="local-6989586621680855219"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855219"><span class="hs-identifier hs-var">cenv2</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-247"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-var">TCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855218"><span class="hs-identifier hs-var">is3</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855217"><span class="hs-identifier hs-var">tenv3</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855216"><span class="hs-identifier hs-var">cenv3</span></a></span><span>
</span><span id="line-248"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-249"></span><span>    </span><span id="local-6989586621680855218"><span class="annot"><span class="annottext">is3 :: InScopeSet
</span><a href="#local-6989586621680855218"><span class="hs-identifier hs-var hs-var">is3</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855224"><span class="hs-identifier hs-var">is1</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; InScopeSet -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#unionInScope"><span class="hs-operator hs-var">`unionInScope`</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855221"><span class="hs-identifier hs-var">is2</span></a></span><span>
</span><span id="line-250"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680855217"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855217"><span class="hs-identifier hs-var">tenv3</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680855216"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855216"><span class="hs-identifier hs-var">cenv3</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet
-&gt; (TvSubstEnv, CvSubstEnv)
-&gt; (TvSubstEnv, CvSubstEnv)
-&gt; (TvSubstEnv, CvSubstEnv)
</span><a href="GHC.Core.TyCo.Subst.html#composeTCvSubstEnv"><span class="hs-identifier hs-var">composeTCvSubstEnv</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855218"><span class="hs-identifier hs-var">is3</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855223"><span class="hs-identifier hs-var">tenv1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855222"><span class="hs-identifier hs-var">cenv1</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855220"><span class="hs-identifier hs-var">tenv2</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855219"><span class="hs-identifier hs-var">cenv2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-251"></span><span>
</span><span id="line-252"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#emptyTCvSubst"><span class="hs-identifier hs-type">emptyTCvSubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-253"></span><span id="emptyTCvSubst"><span class="annot"><span class="annottext">emptyTCvSubst :: TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#emptyTCvSubst"><span class="hs-identifier hs-var hs-var">emptyTCvSubst</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-var">TCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="GHC.Types.Var.Env.html#emptyInScopeSet"><span class="hs-identifier hs-var">emptyInScopeSet</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="GHC.Core.TyCo.Subst.html#emptyTvSubstEnv"><span class="hs-identifier hs-var">emptyTvSubstEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="GHC.Core.TyCo.Subst.html#emptyCvSubstEnv"><span class="hs-identifier hs-var">emptyCvSubstEnv</span></a></span><span>
</span><span id="line-254"></span><span>
</span><span id="line-255"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#mkEmptyTCvSubst"><span class="hs-identifier hs-type">mkEmptyTCvSubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#InScopeSet"><span class="hs-identifier hs-type">InScopeSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-256"></span><span id="mkEmptyTCvSubst"><span class="annot"><span class="annottext">mkEmptyTCvSubst :: InScopeSet -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#mkEmptyTCvSubst"><span class="hs-identifier hs-var hs-var">mkEmptyTCvSubst</span></a></span></span><span> </span><span id="local-6989586621680855213"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855213"><span class="hs-identifier hs-var">is</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-var">TCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855213"><span class="hs-identifier hs-var">is</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="GHC.Core.TyCo.Subst.html#emptyTvSubstEnv"><span class="hs-identifier hs-var">emptyTvSubstEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="GHC.Core.TyCo.Subst.html#emptyCvSubstEnv"><span class="hs-identifier hs-var">emptyCvSubstEnv</span></a></span><span>
</span><span id="line-257"></span><span>
</span><span id="line-258"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#isEmptyTCvSubst"><span class="hs-identifier hs-type">isEmptyTCvSubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-259"></span><span>         </span><span class="hs-comment">-- See Note [Extending the TvSubstEnv]</span><span>
</span><span id="line-260"></span><span id="isEmptyTCvSubst"><span class="annot"><span class="annottext">isEmptyTCvSubst :: TCvSubst -&gt; Bool
</span><a href="GHC.Core.TyCo.Subst.html#isEmptyTCvSubst"><span class="hs-identifier hs-var hs-var">isEmptyTCvSubst</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680855212"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855212"><span class="hs-identifier hs-var">tenv</span></a></span></span><span> </span><span id="local-6989586621680855211"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855211"><span class="hs-identifier hs-var">cenv</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv -&gt; Bool
forall a. VarEnv a -&gt; Bool
</span><a href="GHC.Types.Var.Env.html#isEmptyVarEnv"><span class="hs-identifier hs-var">isEmptyVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855212"><span class="hs-identifier hs-var">tenv</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv -&gt; Bool
forall a. VarEnv a -&gt; Bool
</span><a href="GHC.Types.Var.Env.html#isEmptyVarEnv"><span class="hs-identifier hs-var">isEmptyVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855211"><span class="hs-identifier hs-var">cenv</span></a></span><span>
</span><span id="line-261"></span><span>
</span><span id="line-262"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#mkTCvSubst"><span class="hs-identifier hs-type">mkTCvSubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#InScopeSet"><span class="hs-identifier hs-type">InScopeSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TvSubstEnv"><span class="hs-identifier hs-type">TvSubstEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#CvSubstEnv"><span class="hs-identifier hs-type">CvSubstEnv</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-263"></span><span id="mkTCvSubst"><span class="annot"><span class="annottext">mkTCvSubst :: InScopeSet -&gt; (TvSubstEnv, CvSubstEnv) -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#mkTCvSubst"><span class="hs-identifier hs-var hs-var">mkTCvSubst</span></a></span></span><span> </span><span id="local-6989586621680855208"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855208"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680855207"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855207"><span class="hs-identifier hs-var">tenv</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680855206"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855206"><span class="hs-identifier hs-var">cenv</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-var">TCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855208"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855207"><span class="hs-identifier hs-var">tenv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855206"><span class="hs-identifier hs-var">cenv</span></a></span><span>
</span><span id="line-264"></span><span>
</span><span id="line-265"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#mkTvSubst"><span class="hs-identifier hs-type">mkTvSubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#InScopeSet"><span class="hs-identifier hs-type">InScopeSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TvSubstEnv"><span class="hs-identifier hs-type">TvSubstEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-266"></span><span class="hs-comment">-- ^ Make a TCvSubst with specified tyvar subst and empty covar subst</span><span>
</span><span id="line-267"></span><span id="mkTvSubst"><span class="annot"><span class="annottext">mkTvSubst :: InScopeSet -&gt; TvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#mkTvSubst"><span class="hs-identifier hs-var hs-var">mkTvSubst</span></a></span></span><span> </span><span id="local-6989586621680855205"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855205"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680855204"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855204"><span class="hs-identifier hs-var">tenv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-var">TCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855205"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855204"><span class="hs-identifier hs-var">tenv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="GHC.Core.TyCo.Subst.html#emptyCvSubstEnv"><span class="hs-identifier hs-var">emptyCvSubstEnv</span></a></span><span>
</span><span id="line-268"></span><span>
</span><span id="line-269"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#mkCvSubst"><span class="hs-identifier hs-type">mkCvSubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#InScopeSet"><span class="hs-identifier hs-type">InScopeSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#CvSubstEnv"><span class="hs-identifier hs-type">CvSubstEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-270"></span><span class="hs-comment">-- ^ Make a TCvSubst with specified covar subst and empty tyvar subst</span><span>
</span><span id="line-271"></span><span id="mkCvSubst"><span class="annot"><span class="annottext">mkCvSubst :: InScopeSet -&gt; CvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#mkCvSubst"><span class="hs-identifier hs-var hs-var">mkCvSubst</span></a></span></span><span> </span><span id="local-6989586621680855203"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855203"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680855202"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855202"><span class="hs-identifier hs-var">cenv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-var">TCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855203"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="GHC.Core.TyCo.Subst.html#emptyTvSubstEnv"><span class="hs-identifier hs-var">emptyTvSubstEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855202"><span class="hs-identifier hs-var">cenv</span></a></span><span>
</span><span id="line-272"></span><span>
</span><span id="line-273"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#getTvSubstEnv"><span class="hs-identifier hs-type">getTvSubstEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TvSubstEnv"><span class="hs-identifier hs-type">TvSubstEnv</span></a></span><span>
</span><span id="line-274"></span><span id="getTvSubstEnv"><span class="annot"><span class="annottext">getTvSubstEnv :: TCvSubst -&gt; TvSubstEnv
</span><a href="GHC.Core.TyCo.Subst.html#getTvSubstEnv"><span class="hs-identifier hs-var hs-var">getTvSubstEnv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680855201"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855201"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855201"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-275"></span><span>
</span><span id="line-276"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#getCvSubstEnv"><span class="hs-identifier hs-type">getCvSubstEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#CvSubstEnv"><span class="hs-identifier hs-type">CvSubstEnv</span></a></span><span>
</span><span id="line-277"></span><span id="getCvSubstEnv"><span class="annot"><span class="annottext">getCvSubstEnv :: TCvSubst -&gt; CvSubstEnv
</span><a href="GHC.Core.TyCo.Subst.html#getCvSubstEnv"><span class="hs-identifier hs-var hs-var">getCvSubstEnv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680855200"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855200"><span class="hs-identifier hs-var">env</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855200"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-278"></span><span>
</span><span id="line-279"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#getTCvInScope"><span class="hs-identifier hs-type">getTCvInScope</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#InScopeSet"><span class="hs-identifier hs-type">InScopeSet</span></a></span><span>
</span><span id="line-280"></span><span id="getTCvInScope"><span class="annot"><span class="annottext">getTCvInScope :: TCvSubst -&gt; InScopeSet
</span><a href="GHC.Core.TyCo.Subst.html#getTCvInScope"><span class="hs-identifier hs-var hs-var">getTCvInScope</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span id="local-6989586621680855199"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855199"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855199"><span class="hs-identifier hs-var">in_scope</span></a></span><span>
</span><span id="line-281"></span><span>
</span><span id="line-282"></span><span class="hs-comment">-- | Returns the free variables of the types in the range of a substitution as</span><span>
</span><span id="line-283"></span><span class="hs-comment">-- a non-deterministic set.</span><span>
</span><span id="line-284"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#getTCvSubstRangeFVs"><span class="hs-identifier hs-type">getTCvSubstRangeFVs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span>
</span><span id="line-285"></span><span id="getTCvSubstRangeFVs"><span class="annot"><span class="annottext">getTCvSubstRangeFVs :: TCvSubst -&gt; VarSet
</span><a href="GHC.Core.TyCo.Subst.html#getTCvSubstRangeFVs"><span class="hs-identifier hs-var hs-var">getTCvSubstRangeFVs</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680855198"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855198"><span class="hs-identifier hs-var">tenv</span></a></span></span><span> </span><span id="local-6989586621680855197"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855197"><span class="hs-identifier hs-var">cenv</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-286"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#unionVarSet"><span class="hs-identifier hs-var">unionVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680855195"><span class="hs-identifier hs-var">tenvFVs</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680855194"><span class="hs-identifier hs-var">cenvFVs</span></a></span><span>
</span><span id="line-287"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-288"></span><span>    </span><span id="local-6989586621680855195"><span class="annot"><span class="annottext">tenvFVs :: VarSet
</span><a href="#local-6989586621680855195"><span class="hs-identifier hs-var hs-var">tenvFVs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#shallowTyCoVarsOfTyVarEnv"><span class="hs-identifier hs-var">shallowTyCoVarsOfTyVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855198"><span class="hs-identifier hs-var">tenv</span></a></span><span>
</span><span id="line-289"></span><span>    </span><span id="local-6989586621680855194"><span class="annot"><span class="annottext">cenvFVs :: VarSet
</span><a href="#local-6989586621680855194"><span class="hs-identifier hs-var hs-var">cenvFVs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#shallowTyCoVarsOfCoVarEnv"><span class="hs-identifier hs-var">shallowTyCoVarsOfCoVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855197"><span class="hs-identifier hs-var">cenv</span></a></span><span>
</span><span id="line-290"></span><span>
</span><span id="line-291"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#isInScope"><span class="hs-identifier hs-type">isInScope</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-292"></span><span id="isInScope"><span class="annot"><span class="annottext">isInScope :: TyCoVar -&gt; TCvSubst -&gt; Bool
</span><a href="GHC.Core.TyCo.Subst.html#isInScope"><span class="hs-identifier hs-var hs-var">isInScope</span></a></span></span><span> </span><span id="local-6989586621680855190"><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855190"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span id="local-6989586621680855189"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855189"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855190"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar -&gt; InScopeSet -&gt; Bool
</span><a href="GHC.Types.Var.Env.html#elemInScopeSet"><span class="hs-operator hs-var">`elemInScopeSet`</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855189"><span class="hs-identifier hs-var">in_scope</span></a></span><span>
</span><span id="line-293"></span><span>
</span><span id="line-294"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#notElemTCvSubst"><span class="hs-identifier hs-type">notElemTCvSubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-295"></span><span id="notElemTCvSubst"><span class="annot"><span class="annottext">notElemTCvSubst :: TyCoVar -&gt; TCvSubst -&gt; Bool
</span><a href="GHC.Core.TyCo.Subst.html#notElemTCvSubst"><span class="hs-identifier hs-var hs-var">notElemTCvSubst</span></a></span></span><span> </span><span id="local-6989586621680855187"><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855187"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680855186"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855186"><span class="hs-identifier hs-var">tenv</span></a></span></span><span> </span><span id="local-6989586621680855185"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855185"><span class="hs-identifier hs-var">cenv</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-296"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCoVar -&gt; Bool
</span><a href="GHC.Types.Var.html#isTyVar"><span class="hs-identifier hs-var">isTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855187"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-297"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855187"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar -&gt; TvSubstEnv -&gt; Bool
forall a. TyCoVar -&gt; VarEnv a -&gt; Bool
</span><a href="GHC.Types.Var.Env.html#elemVarEnv"><span class="hs-operator hs-var">`elemVarEnv`</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855186"><span class="hs-identifier hs-var">tenv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-298"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-299"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855187"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar -&gt; CvSubstEnv -&gt; Bool
forall a. TyCoVar -&gt; VarEnv a -&gt; Bool
</span><a href="GHC.Types.Var.Env.html#elemVarEnv"><span class="hs-operator hs-var">`elemVarEnv`</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855185"><span class="hs-identifier hs-var">cenv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-300"></span><span>
</span><span id="line-301"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#setTvSubstEnv"><span class="hs-identifier hs-type">setTvSubstEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TvSubstEnv"><span class="hs-identifier hs-type">TvSubstEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-302"></span><span id="setTvSubstEnv"><span class="annot"><span class="annottext">setTvSubstEnv :: TCvSubst -&gt; TvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#setTvSubstEnv"><span class="hs-identifier hs-var hs-var">setTvSubstEnv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span id="local-6989586621680855181"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855181"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680855180"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855180"><span class="hs-identifier hs-var">cenv</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680855179"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855179"><span class="hs-identifier hs-var">tenv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-var">TCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855181"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855179"><span class="hs-identifier hs-var">tenv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855180"><span class="hs-identifier hs-var">cenv</span></a></span><span>
</span><span id="line-303"></span><span>
</span><span id="line-304"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#setCvSubstEnv"><span class="hs-identifier hs-type">setCvSubstEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#CvSubstEnv"><span class="hs-identifier hs-type">CvSubstEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-305"></span><span id="setCvSubstEnv"><span class="annot"><span class="annottext">setCvSubstEnv :: TCvSubst -&gt; CvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#setCvSubstEnv"><span class="hs-identifier hs-var hs-var">setCvSubstEnv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span id="local-6989586621680855178"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855178"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680855177"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855177"><span class="hs-identifier hs-var">tenv</span></a></span></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680855176"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855176"><span class="hs-identifier hs-var">cenv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-var">TCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855178"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855177"><span class="hs-identifier hs-var">tenv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855176"><span class="hs-identifier hs-var">cenv</span></a></span><span>
</span><span id="line-306"></span><span>
</span><span id="line-307"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#zapTCvSubst"><span class="hs-identifier hs-type">zapTCvSubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-308"></span><span id="zapTCvSubst"><span class="annot"><span class="annottext">zapTCvSubst :: TCvSubst -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#zapTCvSubst"><span class="hs-identifier hs-var hs-var">zapTCvSubst</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span id="local-6989586621680855175"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855175"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-var">TCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855175"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
forall a. VarEnv a
</span><a href="GHC.Types.Var.Env.html#emptyVarEnv"><span class="hs-identifier hs-var">emptyVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
forall a. VarEnv a
</span><a href="GHC.Types.Var.Env.html#emptyVarEnv"><span class="hs-identifier hs-var">emptyVarEnv</span></a></span><span>
</span><span id="line-309"></span><span>
</span><span id="line-310"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#extendTCvInScope"><span class="hs-identifier hs-type">extendTCvInScope</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-311"></span><span id="extendTCvInScope"><span class="annot"><span class="annottext">extendTCvInScope :: TCvSubst -&gt; TyCoVar -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#extendTCvInScope"><span class="hs-identifier hs-var hs-var">extendTCvInScope</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span id="local-6989586621680855174"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855174"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680855173"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855173"><span class="hs-identifier hs-var">tenv</span></a></span></span><span> </span><span id="local-6989586621680855172"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855172"><span class="hs-identifier hs-var">cenv</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680855171"><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855171"><span class="hs-identifier hs-var">var</span></a></span></span><span>
</span><span id="line-312"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-var">TCvSubst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet -&gt; TyCoVar -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#extendInScopeSet"><span class="hs-identifier hs-var">extendInScopeSet</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855174"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855171"><span class="hs-identifier hs-var">var</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855173"><span class="hs-identifier hs-var">tenv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855172"><span class="hs-identifier hs-var">cenv</span></a></span><span>
</span><span id="line-313"></span><span>
</span><span id="line-314"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#extendTCvInScopeList"><span class="hs-identifier hs-type">extendTCvInScopeList</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-315"></span><span id="extendTCvInScopeList"><span class="annot"><span class="annottext">extendTCvInScopeList :: TCvSubst -&gt; [TyCoVar] -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#extendTCvInScopeList"><span class="hs-identifier hs-var hs-var">extendTCvInScopeList</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span id="local-6989586621680855169"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855169"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680855168"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855168"><span class="hs-identifier hs-var">tenv</span></a></span></span><span> </span><span id="local-6989586621680855167"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855167"><span class="hs-identifier hs-var">cenv</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680855166"><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680855166"><span class="hs-identifier hs-var">vars</span></a></span></span><span>
</span><span id="line-316"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-var">TCvSubst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet -&gt; [TyCoVar] -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#extendInScopeSetList"><span class="hs-identifier hs-var">extendInScopeSetList</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855169"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680855166"><span class="hs-identifier hs-var">vars</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855168"><span class="hs-identifier hs-var">tenv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855167"><span class="hs-identifier hs-var">cenv</span></a></span><span>
</span><span id="line-317"></span><span>
</span><span id="line-318"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#extendTCvInScopeSet"><span class="hs-identifier hs-type">extendTCvInScopeSet</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-319"></span><span id="extendTCvInScopeSet"><span class="annot"><span class="annottext">extendTCvInScopeSet :: TCvSubst -&gt; VarSet -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#extendTCvInScopeSet"><span class="hs-identifier hs-var hs-var">extendTCvInScopeSet</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span id="local-6989586621680855164"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855164"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680855163"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855163"><span class="hs-identifier hs-var">tenv</span></a></span></span><span> </span><span id="local-6989586621680855162"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855162"><span class="hs-identifier hs-var">cenv</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680855161"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680855161"><span class="hs-identifier hs-var">vars</span></a></span></span><span>
</span><span id="line-320"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-var">TCvSubst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet -&gt; VarSet -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#extendInScopeSetSet"><span class="hs-identifier hs-var">extendInScopeSetSet</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855164"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680855161"><span class="hs-identifier hs-var">vars</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855163"><span class="hs-identifier hs-var">tenv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855162"><span class="hs-identifier hs-var">cenv</span></a></span><span>
</span><span id="line-321"></span><span>
</span><span id="line-322"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#extendTCvSubst"><span class="hs-identifier hs-type">extendTCvSubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-323"></span><span id="extendTCvSubst"><span class="annot"><span class="annottext">extendTCvSubst :: TCvSubst -&gt; TyCoVar -&gt; Type -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#extendTCvSubst"><span class="hs-identifier hs-var hs-var">extendTCvSubst</span></a></span></span><span> </span><span id="local-6989586621680855159"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680855159"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680855158"><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855158"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span id="local-6989586621680855157"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680855157"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-324"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCoVar -&gt; Bool
</span><a href="GHC.Types.Var.html#isTyVar"><span class="hs-identifier hs-var">isTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855158"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-325"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; TyCoVar -&gt; Type -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#extendTvSubst"><span class="hs-identifier hs-var">extendTvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680855159"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855158"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680855157"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-326"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CoercionTy"><span class="hs-identifier hs-type">CoercionTy</span></a></span><span> </span><span id="local-6989586621680855155"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680855155"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680855157"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-327"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; TyCoVar -&gt; Coercion -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#extendCvSubst"><span class="hs-identifier hs-var">extendCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680855159"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855158"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680855155"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-328"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-329"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TCvSubst
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;extendTCvSubst&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCoVar -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855158"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;|-&gt;&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680855157"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-330"></span><span>
</span><span id="line-331"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#extendTCvSubstWithClone"><span class="hs-identifier hs-type">extendTCvSubstWithClone</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-332"></span><span id="extendTCvSubstWithClone"><span class="annot"><span class="annottext">extendTCvSubstWithClone :: TCvSubst -&gt; TyCoVar -&gt; TyCoVar -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#extendTCvSubstWithClone"><span class="hs-identifier hs-var hs-var">extendTCvSubstWithClone</span></a></span></span><span> </span><span id="local-6989586621680855150"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680855150"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680855149"><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855149"><span class="hs-identifier hs-var">tcv</span></a></span></span><span>
</span><span id="line-333"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCoVar -&gt; Bool
</span><a href="GHC.Types.Var.html#isTyVar"><span class="hs-identifier hs-var">isTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855149"><span class="hs-identifier hs-var">tcv</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; TyCoVar -&gt; TyCoVar -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#extendTvSubstWithClone"><span class="hs-identifier hs-var">extendTvSubstWithClone</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680855150"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855149"><span class="hs-identifier hs-var">tcv</span></a></span><span>
</span><span id="line-334"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; TyCoVar -&gt; TyCoVar -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#extendCvSubstWithClone"><span class="hs-identifier hs-var">extendCvSubstWithClone</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680855150"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855149"><span class="hs-identifier hs-var">tcv</span></a></span><span>
</span><span id="line-335"></span><span>
</span><span id="line-336"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#extendTvSubst"><span class="hs-identifier hs-type">extendTvSubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-337"></span><span id="extendTvSubst"><span class="annot"><span class="annottext">extendTvSubst :: TCvSubst -&gt; TyCoVar -&gt; Type -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#extendTvSubst"><span class="hs-identifier hs-var hs-var">extendTvSubst</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span id="local-6989586621680855147"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855147"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680855146"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855146"><span class="hs-identifier hs-var">tenv</span></a></span></span><span> </span><span id="local-6989586621680855145"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855145"><span class="hs-identifier hs-var">cenv</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680855144"><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855144"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span id="local-6989586621680855143"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680855143"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-338"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-var">TCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855147"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TvSubstEnv -&gt; TyCoVar -&gt; Type -&gt; TvSubstEnv
forall a. VarEnv a -&gt; TyCoVar -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnv"><span class="hs-identifier hs-var">extendVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855146"><span class="hs-identifier hs-var">tenv</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855144"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680855143"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855145"><span class="hs-identifier hs-var">cenv</span></a></span><span>
</span><span id="line-339"></span><span>
</span><span id="line-340"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#extendTvSubstBinderAndInScope"><span class="hs-identifier hs-type">extendTvSubstBinderAndInScope</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyCoBinder"><span class="hs-identifier hs-type">TyCoBinder</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-341"></span><span id="extendTvSubstBinderAndInScope"><span class="annot"><span class="annottext">extendTvSubstBinderAndInScope :: TCvSubst -&gt; TyCoBinder -&gt; Type -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#extendTvSubstBinderAndInScope"><span class="hs-identifier hs-var hs-var">extendTvSubstBinderAndInScope</span></a></span></span><span> </span><span id="local-6989586621680855141"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680855141"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Named"><span class="hs-identifier hs-type">Named</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Bndr"><span class="hs-identifier hs-type">Bndr</span></a></span><span> </span><span id="local-6989586621680855138"><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855138"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span class="annot"><span class="annottext">ArgFlag
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span id="local-6989586621680855137"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680855137"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-342"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isTyVar</span><span> </span><span class="hs-identifier">v</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-343"></span><span>    </span><span class="annot"><span class="annottext">TCvSubst -&gt; TyCoVar -&gt; Type -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#extendTvSubstAndInScope"><span class="hs-identifier hs-var">extendTvSubstAndInScope</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680855141"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855138"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680855137"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-344"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#extendTvSubstBinderAndInScope"><span class="hs-identifier hs-var">extendTvSubstBinderAndInScope</span></a></span><span> </span><span id="local-6989586621680855134"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680855134"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Anon"><span class="hs-identifier hs-type">Anon</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span>
</span><span id="line-345"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680855134"><span class="hs-identifier hs-var">subst</span></a></span><span>
</span><span id="line-346"></span><span>
</span><span id="line-347"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#extendTvSubstWithClone"><span class="hs-identifier hs-type">extendTvSubstWithClone</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-348"></span><span class="hs-comment">-- Adds a new tv -&gt; tv mapping, /and/ extends the in-scope set</span><span>
</span><span id="line-349"></span><span id="extendTvSubstWithClone"><span class="annot"><span class="annottext">extendTvSubstWithClone :: TCvSubst -&gt; TyCoVar -&gt; TyCoVar -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#extendTvSubstWithClone"><span class="hs-identifier hs-var hs-var">extendTvSubstWithClone</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span id="local-6989586621680855132"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855132"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680855131"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855131"><span class="hs-identifier hs-var">tenv</span></a></span></span><span> </span><span id="local-6989586621680855130"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855130"><span class="hs-identifier hs-var">cenv</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680855129"><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855129"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span id="local-6989586621680855128"><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855128"><span class="hs-identifier hs-var">tv'</span></a></span></span><span>
</span><span id="line-350"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-var">TCvSubst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet -&gt; VarSet -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#extendInScopeSetSet"><span class="hs-identifier hs-var">extendInScopeSetSet</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855132"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680855127"><span class="hs-identifier hs-var">new_in_scope</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-351"></span><span>             </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TvSubstEnv -&gt; TyCoVar -&gt; Type -&gt; TvSubstEnv
forall a. VarEnv a -&gt; TyCoVar -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnv"><span class="hs-identifier hs-var">extendVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855131"><span class="hs-identifier hs-var">tenv</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855129"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCoVar -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTy"><span class="hs-identifier hs-var">mkTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855128"><span class="hs-identifier hs-var">tv'</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-352"></span><span>             </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855130"><span class="hs-identifier hs-var">cenv</span></a></span><span>
</span><span id="line-353"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-354"></span><span>    </span><span id="local-6989586621680855127"><span class="annot"><span class="annottext">new_in_scope :: VarSet
</span><a href="#local-6989586621680855127"><span class="hs-identifier hs-var hs-var">new_in_scope</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfType"><span class="hs-identifier hs-var">tyCoVarsOfType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCoVar -&gt; Type
</span><a href="GHC.Types.Var.html#tyVarKind"><span class="hs-identifier hs-var">tyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855128"><span class="hs-identifier hs-var">tv'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; TyCoVar -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#extendVarSet"><span class="hs-operator hs-var">`extendVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855128"><span class="hs-identifier hs-var">tv'</span></a></span><span>
</span><span id="line-355"></span><span>
</span><span id="line-356"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#extendCvSubst"><span class="hs-identifier hs-type">extendCvSubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#CoVar"><span class="hs-identifier hs-type">CoVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-357"></span><span id="extendCvSubst"><span class="annot"><span class="annottext">extendCvSubst :: TCvSubst -&gt; TyCoVar -&gt; Coercion -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#extendCvSubst"><span class="hs-identifier hs-var hs-var">extendCvSubst</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span id="local-6989586621680855121"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855121"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680855120"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855120"><span class="hs-identifier hs-var">tenv</span></a></span></span><span> </span><span id="local-6989586621680855119"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855119"><span class="hs-identifier hs-var">cenv</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680855118"><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855118"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span id="local-6989586621680855117"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680855117"><span class="hs-identifier hs-var">co</span></a></span></span><span>
</span><span id="line-358"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-var">TCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855121"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855120"><span class="hs-identifier hs-var">tenv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CvSubstEnv -&gt; TyCoVar -&gt; Coercion -&gt; CvSubstEnv
forall a. VarEnv a -&gt; TyCoVar -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnv"><span class="hs-identifier hs-var">extendVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855119"><span class="hs-identifier hs-var">cenv</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855118"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680855117"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-359"></span><span>
</span><span id="line-360"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#extendCvSubstWithClone"><span class="hs-identifier hs-type">extendCvSubstWithClone</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#CoVar"><span class="hs-identifier hs-type">CoVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#CoVar"><span class="hs-identifier hs-type">CoVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-361"></span><span id="extendCvSubstWithClone"><span class="annot"><span class="annottext">extendCvSubstWithClone :: TCvSubst -&gt; TyCoVar -&gt; TyCoVar -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#extendCvSubstWithClone"><span class="hs-identifier hs-var hs-var">extendCvSubstWithClone</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span id="local-6989586621680855116"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855116"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680855115"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855115"><span class="hs-identifier hs-var">tenv</span></a></span></span><span> </span><span id="local-6989586621680855114"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855114"><span class="hs-identifier hs-var">cenv</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680855113"><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855113"><span class="hs-identifier hs-var">cv</span></a></span></span><span> </span><span id="local-6989586621680855112"><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855112"><span class="hs-identifier hs-var">cv'</span></a></span></span><span>
</span><span id="line-362"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-var">TCvSubst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet -&gt; VarSet -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#extendInScopeSetSet"><span class="hs-identifier hs-var">extendInScopeSetSet</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855116"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680855111"><span class="hs-identifier hs-var">new_in_scope</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-363"></span><span>             </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855115"><span class="hs-identifier hs-var">tenv</span></a></span><span>
</span><span id="line-364"></span><span>             </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CvSubstEnv -&gt; TyCoVar -&gt; Coercion -&gt; CvSubstEnv
forall a. VarEnv a -&gt; TyCoVar -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnv"><span class="hs-identifier hs-var">extendVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855114"><span class="hs-identifier hs-var">cenv</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855113"><span class="hs-identifier hs-var">cv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCoVar -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkCoVarCo"><span class="hs-identifier hs-var">mkCoVarCo</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855112"><span class="hs-identifier hs-var">cv'</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-365"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-366"></span><span>    </span><span id="local-6989586621680855111"><span class="annot"><span class="annottext">new_in_scope :: VarSet
</span><a href="#local-6989586621680855111"><span class="hs-identifier hs-var hs-var">new_in_scope</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfType"><span class="hs-identifier hs-var">tyCoVarsOfType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCoVar -&gt; Type
</span><a href="GHC.Types.Var.html#varType"><span class="hs-identifier hs-var hs-var">varType</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855112"><span class="hs-identifier hs-var">cv'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; TyCoVar -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#extendVarSet"><span class="hs-operator hs-var">`extendVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855112"><span class="hs-identifier hs-var">cv'</span></a></span><span>
</span><span id="line-367"></span><span>
</span><span id="line-368"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#extendTvSubstAndInScope"><span class="hs-identifier hs-type">extendTvSubstAndInScope</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-369"></span><span class="hs-comment">-- Also extends the in-scope set</span><span>
</span><span id="line-370"></span><span id="extendTvSubstAndInScope"><span class="annot"><span class="annottext">extendTvSubstAndInScope :: TCvSubst -&gt; TyCoVar -&gt; Type -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#extendTvSubstAndInScope"><span class="hs-identifier hs-var hs-var">extendTvSubstAndInScope</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span id="local-6989586621680855109"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855109"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680855108"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855108"><span class="hs-identifier hs-var">tenv</span></a></span></span><span> </span><span id="local-6989586621680855107"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855107"><span class="hs-identifier hs-var">cenv</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680855106"><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855106"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span id="local-6989586621680855105"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680855105"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-371"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-var">TCvSubst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855109"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; VarSet -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#extendInScopeSetSet"><span class="hs-operator hs-var">`extendInScopeSetSet`</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfType"><span class="hs-identifier hs-var">tyCoVarsOfType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680855105"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-372"></span><span>             </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TvSubstEnv -&gt; TyCoVar -&gt; Type -&gt; TvSubstEnv
forall a. VarEnv a -&gt; TyCoVar -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnv"><span class="hs-identifier hs-var">extendVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855108"><span class="hs-identifier hs-var">tenv</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855106"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680855105"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-373"></span><span>             </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855107"><span class="hs-identifier hs-var">cenv</span></a></span><span>
</span><span id="line-374"></span><span>
</span><span id="line-375"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#extendTvSubstList"><span class="hs-identifier hs-type">extendTvSubstList</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-376"></span><span id="extendTvSubstList"><span class="annot"><span class="annottext">extendTvSubstList :: TCvSubst -&gt; [TyCoVar] -&gt; [Type] -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#extendTvSubstList"><span class="hs-identifier hs-var hs-var">extendTvSubstList</span></a></span></span><span> </span><span id="local-6989586621680855104"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680855104"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680855103"><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680855103"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621680855102"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680855102"><span class="hs-identifier hs-var">tys</span></a></span></span><span>
</span><span id="line-377"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TCvSubst -&gt; TyCoVar -&gt; Type -&gt; TCvSubst)
-&gt; TCvSubst -&gt; [TyCoVar] -&gt; [Type] -&gt; TCvSubst
forall acc a b. (acc -&gt; a -&gt; b -&gt; acc) -&gt; acc -&gt; [a] -&gt; [b] -&gt; acc
</span><a href="GHC.Utils.Misc.html#foldl2"><span class="hs-identifier hs-var">foldl2</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; TyCoVar -&gt; Type -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#extendTvSubst"><span class="hs-identifier hs-var">extendTvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680855104"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680855103"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680855102"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-378"></span><span>
</span><span id="line-379"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#extendTCvSubstList"><span class="hs-identifier hs-type">extendTCvSubstList</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-380"></span><span id="extendTCvSubstList"><span class="annot"><span class="annottext">extendTCvSubstList :: TCvSubst -&gt; [TyCoVar] -&gt; [Type] -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#extendTCvSubstList"><span class="hs-identifier hs-var hs-var">extendTCvSubstList</span></a></span></span><span> </span><span id="local-6989586621680855100"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680855100"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680855099"><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680855099"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621680855098"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680855098"><span class="hs-identifier hs-var">tys</span></a></span></span><span>
</span><span id="line-381"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TCvSubst -&gt; TyCoVar -&gt; Type -&gt; TCvSubst)
-&gt; TCvSubst -&gt; [TyCoVar] -&gt; [Type] -&gt; TCvSubst
forall acc a b. (acc -&gt; a -&gt; b -&gt; acc) -&gt; acc -&gt; [a] -&gt; [b] -&gt; acc
</span><a href="GHC.Utils.Misc.html#foldl2"><span class="hs-identifier hs-var">foldl2</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; TyCoVar -&gt; Type -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#extendTCvSubst"><span class="hs-identifier hs-var">extendTCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680855100"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680855099"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680855098"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-382"></span><span>
</span><span id="line-383"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#unionTCvSubst"><span class="hs-identifier hs-type">unionTCvSubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-384"></span><span class="hs-comment">-- Works when the ranges are disjoint</span><span>
</span><span id="line-385"></span><span id="unionTCvSubst"><span class="annot"><span class="annottext">unionTCvSubst :: TCvSubst -&gt; TCvSubst -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#unionTCvSubst"><span class="hs-identifier hs-var hs-var">unionTCvSubst</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span id="local-6989586621680855097"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855097"><span class="hs-identifier hs-var">in_scope1</span></a></span></span><span> </span><span id="local-6989586621680855096"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855096"><span class="hs-identifier hs-var">tenv1</span></a></span></span><span> </span><span id="local-6989586621680855095"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855095"><span class="hs-identifier hs-var">cenv1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span id="local-6989586621680855094"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855094"><span class="hs-identifier hs-var">in_scope2</span></a></span></span><span> </span><span id="local-6989586621680855093"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855093"><span class="hs-identifier hs-var">tenv2</span></a></span></span><span> </span><span id="local-6989586621680855092"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855092"><span class="hs-identifier hs-var">cenv2</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-386"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">tenv1</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">disjointVarEnv</span><span class="hs-special">`</span><span> </span><span class="hs-identifier">tenv2</span><span>
</span><span id="line-387"></span><span>         </span><span class="hs-operator">&amp;&amp;</span><span> </span><span class="hs-identifier">cenv1</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">disjointVarEnv</span><span class="hs-special">`</span><span> </span><span class="hs-identifier">cenv2</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-388"></span><span>    </span><span class="annot"><span class="annottext">InScopeSet -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-var">TCvSubst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855097"><span class="hs-identifier hs-var">in_scope1</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; InScopeSet -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#unionInScope"><span class="hs-operator hs-var">`unionInScope`</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855094"><span class="hs-identifier hs-var">in_scope2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-389"></span><span>             </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855096"><span class="hs-identifier hs-var">tenv1</span></a></span><span>     </span><span class="annot"><span class="annottext">TvSubstEnv -&gt; TvSubstEnv -&gt; TvSubstEnv
forall a. VarEnv a -&gt; VarEnv a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#plusVarEnv"><span class="hs-operator hs-var">`plusVarEnv`</span></a></span><span>   </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855093"><span class="hs-identifier hs-var">tenv2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-390"></span><span>             </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855095"><span class="hs-identifier hs-var">cenv1</span></a></span><span>     </span><span class="annot"><span class="annottext">CvSubstEnv -&gt; CvSubstEnv -&gt; CvSubstEnv
forall a. VarEnv a -&gt; VarEnv a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#plusVarEnv"><span class="hs-operator hs-var">`plusVarEnv`</span></a></span><span>   </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855092"><span class="hs-identifier hs-var">cenv2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-391"></span><span>
</span><span id="line-392"></span><span class="hs-comment">-- mkTvSubstPrs and zipTvSubst generate the in-scope set from</span><span>
</span><span id="line-393"></span><span class="hs-comment">-- the types given; but it's just a thunk so with a bit of luck</span><span>
</span><span id="line-394"></span><span class="hs-comment">-- it'll never be evaluated</span><span>
</span><span id="line-395"></span><span>
</span><span id="line-396"></span><span class="hs-comment">-- | Generates the in-scope set for the 'TCvSubst' from the types in the incoming</span><span>
</span><span id="line-397"></span><span class="hs-comment">-- environment. No CoVars, please!</span><span>
</span><span id="line-398"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#zipTvSubst"><span class="hs-identifier hs-type">zipTvSubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html#HasDebugCallStack"><span class="hs-identifier hs-type">HasDebugCallStack</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-399"></span><span id="zipTvSubst"><span class="annot"><span class="annottext">zipTvSubst :: HasDebugCallStack =&gt; [TyCoVar] -&gt; [Type] -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#zipTvSubst"><span class="hs-identifier hs-var hs-var">zipTvSubst</span></a></span></span><span> </span><span id="local-6989586621680855089"><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680855089"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621680855088"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680855088"><span class="hs-identifier hs-var">tys</span></a></span></span><span>
</span><span id="line-400"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#mkTvSubst"><span class="hs-identifier hs-var">mkTvSubst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#mkInScopeSet"><span class="hs-identifier hs-var">mkInScopeSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Type] -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#shallowTyCoVarsOfTypes"><span class="hs-identifier hs-var">shallowTyCoVarsOfTypes</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680855088"><span class="hs-identifier hs-var">tys</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855085"><span class="hs-identifier hs-var">tenv</span></a></span><span>
</span><span id="line-401"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-402"></span><span>    </span><span id="local-6989586621680855085"><span class="annot"><span class="annottext">tenv :: TvSubstEnv
</span><a href="#local-6989586621680855085"><span class="hs-identifier hs-var hs-var">tenv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TyCoVar] -&gt; [Type] -&gt; TvSubstEnv
HasDebugCallStack =&gt; [TyCoVar] -&gt; [Type] -&gt; TvSubstEnv
</span><a href="GHC.Core.TyCo.Subst.html#zipTyEnv"><span class="hs-identifier hs-var">zipTyEnv</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680855089"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680855088"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-403"></span><span>
</span><span id="line-404"></span><span class="hs-comment">-- | Generates the in-scope set for the 'TCvSubst' from the types in the incoming</span><span>
</span><span id="line-405"></span><span class="hs-comment">-- environment.  No TyVars, please!</span><span>
</span><span id="line-406"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#zipCvSubst"><span class="hs-identifier hs-type">zipCvSubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html#HasDebugCallStack"><span class="hs-identifier hs-type">HasDebugCallStack</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#CoVar"><span class="hs-identifier hs-type">CoVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-407"></span><span id="zipCvSubst"><span class="annot"><span class="annottext">zipCvSubst :: HasDebugCallStack =&gt; [TyCoVar] -&gt; [Coercion] -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#zipCvSubst"><span class="hs-identifier hs-var hs-var">zipCvSubst</span></a></span></span><span> </span><span id="local-6989586621680855082"><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680855082"><span class="hs-identifier hs-var">cvs</span></a></span></span><span> </span><span id="local-6989586621680855081"><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680855081"><span class="hs-identifier hs-var">cos</span></a></span></span><span>
</span><span id="line-408"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-var">TCvSubst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#mkInScopeSet"><span class="hs-identifier hs-var">mkInScopeSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Coercion] -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#shallowTyCoVarsOfCos"><span class="hs-identifier hs-var">shallowTyCoVarsOfCos</span></a></span><span> </span><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680855081"><span class="hs-identifier hs-var">cos</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="GHC.Core.TyCo.Subst.html#emptyTvSubstEnv"><span class="hs-identifier hs-var">emptyTvSubstEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855079"><span class="hs-identifier hs-var">cenv</span></a></span><span>
</span><span id="line-409"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-410"></span><span>    </span><span id="local-6989586621680855079"><span class="annot"><span class="annottext">cenv :: CvSubstEnv
</span><a href="#local-6989586621680855079"><span class="hs-identifier hs-var hs-var">cenv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TyCoVar] -&gt; [Coercion] -&gt; CvSubstEnv
HasDebugCallStack =&gt; [TyCoVar] -&gt; [Coercion] -&gt; CvSubstEnv
</span><a href="GHC.Core.TyCo.Subst.html#zipCoEnv"><span class="hs-identifier hs-var">zipCoEnv</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680855082"><span class="hs-identifier hs-var">cvs</span></a></span><span> </span><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680855081"><span class="hs-identifier hs-var">cos</span></a></span><span>
</span><span id="line-411"></span><span>
</span><span id="line-412"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#zipTCvSubst"><span class="hs-identifier hs-type">zipTCvSubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html#HasDebugCallStack"><span class="hs-identifier hs-type">HasDebugCallStack</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-413"></span><span id="zipTCvSubst"><span class="annot"><span class="annottext">zipTCvSubst :: HasDebugCallStack =&gt; [TyCoVar] -&gt; [Type] -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#zipTCvSubst"><span class="hs-identifier hs-var hs-var">zipTCvSubst</span></a></span></span><span> </span><span id="local-6989586621680855072"><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680855072"><span class="hs-identifier hs-var">tcvs</span></a></span></span><span> </span><span id="local-6989586621680855071"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680855071"><span class="hs-identifier hs-var">tys</span></a></span></span><span>
</span><span id="line-414"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TyCoVar] -&gt; [Type] -&gt; TCvSubst -&gt; TCvSubst
</span><a href="#local-6989586621680855070"><span class="hs-identifier hs-var">zip_tcvsubst</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680855072"><span class="hs-identifier hs-var">tcvs</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680855071"><span class="hs-identifier hs-var">tys</span></a></span><span> </span><span class="annot"><span class="annottext">(TCvSubst -&gt; TCvSubst) -&gt; TCvSubst -&gt; TCvSubst
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-415"></span><span>    </span><span class="annot"><span class="annottext">InScopeSet -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#mkEmptyTCvSubst"><span class="hs-identifier hs-var">mkEmptyTCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">(InScopeSet -&gt; TCvSubst) -&gt; InScopeSet -&gt; TCvSubst
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#mkInScopeSet"><span class="hs-identifier hs-var">mkInScopeSet</span></a></span><span> </span><span class="annot"><span class="annottext">(VarSet -&gt; InScopeSet) -&gt; VarSet -&gt; InScopeSet
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#shallowTyCoVarsOfTypes"><span class="hs-identifier hs-var">shallowTyCoVarsOfTypes</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680855071"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-416"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span class="annot"><a href="#local-6989586621680855070"><span class="hs-identifier hs-type">zip_tcvsubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-417"></span><span>        </span><span id="local-6989586621680855070"><span class="annot"><span class="annottext">zip_tcvsubst :: [TyCoVar] -&gt; [Type] -&gt; TCvSubst -&gt; TCvSubst
</span><a href="#local-6989586621680855070"><span class="hs-identifier hs-var hs-var">zip_tcvsubst</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680855069"><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855069"><span class="hs-identifier hs-var">tv</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680855068"><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680855068"><span class="hs-identifier hs-var">tvs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680855067"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680855067"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680855066"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680855066"><span class="hs-identifier hs-var">tys</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680855065"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680855065"><span class="hs-identifier hs-var">subst</span></a></span></span><span>
</span><span id="line-418"></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TyCoVar] -&gt; [Type] -&gt; TCvSubst -&gt; TCvSubst
</span><a href="#local-6989586621680855070"><span class="hs-identifier hs-var">zip_tcvsubst</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680855068"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680855066"><span class="hs-identifier hs-var">tys</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst -&gt; TyCoVar -&gt; Type -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#extendTCvSubst"><span class="hs-identifier hs-var">extendTCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680855065"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855069"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680855067"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-419"></span><span>        </span><span class="annot"><a href="#local-6989586621680855070"><span class="hs-identifier hs-var">zip_tcvsubst</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span id="local-6989586621680855064"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680855064"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680855064"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="hs-comment">-- empty case</span><span>
</span><span id="line-420"></span><span>        </span><span class="annot"><a href="#local-6989586621680855070"><span class="hs-identifier hs-var">zip_tcvsubst</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCoVar]
</span><span class="hs-identifier">_</span></span><span>  </span><span class="annot"><span class="annottext">[Type]
</span><span class="hs-identifier">_</span></span><span>  </span><span class="annot"><span class="annottext">TCvSubst
</span><span class="hs-identifier">_</span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TCvSubst
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;zipTCvSubst: length mismatch&quot;</span></span><span>
</span><span id="line-421"></span><span>                                            </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TyCoVar] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680855072"><span class="hs-identifier hs-var">tcvs</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680855071"><span class="hs-identifier hs-var">tys</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-422"></span><span>
</span><span id="line-423"></span><span class="hs-comment">-- | Generates the in-scope set for the 'TCvSubst' from the types in the</span><span>
</span><span id="line-424"></span><span class="hs-comment">-- incoming environment. No CoVars, please!</span><span>
</span><span id="line-425"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#mkTvSubstPrs"><span class="hs-identifier hs-type">mkTvSubstPrs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-426"></span><span id="mkTvSubstPrs"><span class="annot"><span class="annottext">mkTvSubstPrs :: [(TyCoVar, Type)] -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#mkTvSubstPrs"><span class="hs-identifier hs-var hs-var">mkTvSubstPrs</span></a></span></span><span> </span><span id="local-6989586621680855063"><span class="annot"><span class="annottext">[(TyCoVar, Type)]
</span><a href="#local-6989586621680855063"><span class="hs-identifier hs-var">prs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-427"></span><span>    </span><span class="hs-identifier">ASSERT2</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">onlyTyVarsAndNoCoercionTy</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">text</span><span> </span><span class="hs-string">&quot;prs&quot;</span><span> </span><span class="hs-operator">&lt;+&gt;</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">prs</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-428"></span><span>    </span><span class="annot"><span class="annottext">InScopeSet -&gt; TvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#mkTvSubst"><span class="hs-identifier hs-var">mkTvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855060"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855059"><span class="hs-identifier hs-var">tenv</span></a></span><span>
</span><span id="line-429"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621680855059"><span class="annot"><span class="annottext">tenv :: TvSubstEnv
</span><a href="#local-6989586621680855059"><span class="hs-identifier hs-var hs-var">tenv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(TyCoVar, Type)] -&gt; TvSubstEnv
forall a. [(TyCoVar, a)] -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#mkVarEnv"><span class="hs-identifier hs-var">mkVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">[(TyCoVar, Type)]
</span><a href="#local-6989586621680855063"><span class="hs-identifier hs-var">prs</span></a></span><span>
</span><span id="line-430"></span><span>        </span><span id="local-6989586621680855060"><span class="annot"><span class="annottext">in_scope :: InScopeSet
</span><a href="#local-6989586621680855060"><span class="hs-identifier hs-var hs-var">in_scope</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#mkInScopeSet"><span class="hs-identifier hs-var">mkInScopeSet</span></a></span><span> </span><span class="annot"><span class="annottext">(VarSet -&gt; InScopeSet) -&gt; VarSet -&gt; InScopeSet
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#shallowTyCoVarsOfTypes"><span class="hs-identifier hs-var">shallowTyCoVarsOfTypes</span></a></span><span> </span><span class="annot"><span class="annottext">([Type] -&gt; VarSet) -&gt; [Type] -&gt; VarSet
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">((TyCoVar, Type) -&gt; Type) -&gt; [(TyCoVar, Type)] -&gt; [Type]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(TyCoVar, Type) -&gt; Type
forall a b. (a, b) -&gt; b
</span><a href="../../base/src/Data.Tuple.html#snd"><span class="hs-identifier hs-var">snd</span></a></span><span> </span><span class="annot"><span class="annottext">[(TyCoVar, Type)]
</span><a href="#local-6989586621680855063"><span class="hs-identifier hs-var">prs</span></a></span><span>
</span><span id="line-431"></span><span>        </span><span id="local-6989586621680855062"><span class="annot"><span class="annottext">onlyTyVarsAndNoCoercionTy :: Bool
</span><a href="#local-6989586621680855062"><span class="hs-identifier hs-var hs-var">onlyTyVarsAndNoCoercionTy</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-432"></span><span>          </span><span class="annot"><span class="annottext">[Bool] -&gt; Bool
forall (t :: * -&gt; *). Foldable t =&gt; t Bool -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#and"><span class="hs-identifier hs-var">and</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">TyCoVar -&gt; Bool
</span><a href="GHC.Types.Var.html#isTyVar"><span class="hs-identifier hs-var">isTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855054"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Bool
</span><a href="GHC.Core.Type.html#isCoercionTy"><span class="hs-identifier hs-var">isCoercionTy</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680855053"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-433"></span><span>              </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680855054"><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680855054"><span class="hs-identifier hs-var">tv</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680855053"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680855053"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(TyCoVar, Type)]
</span><a href="#local-6989586621680855063"><span class="hs-identifier hs-var">prs</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-434"></span><span>
</span><span id="line-435"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#zipTyEnv"><span class="hs-identifier hs-type">zipTyEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html#HasDebugCallStack"><span class="hs-identifier hs-type">HasDebugCallStack</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TvSubstEnv"><span class="hs-identifier hs-type">TvSubstEnv</span></a></span><span>
</span><span id="line-436"></span><span id="zipTyEnv"><span class="annot"><span class="annottext">zipTyEnv :: HasDebugCallStack =&gt; [TyCoVar] -&gt; [Type] -&gt; TvSubstEnv
</span><a href="GHC.Core.TyCo.Subst.html#zipTyEnv"><span class="hs-identifier hs-var hs-var">zipTyEnv</span></a></span></span><span> </span><span id="local-6989586621680855045"><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680855045"><span class="hs-identifier hs-var">tyvars</span></a></span></span><span> </span><span id="local-6989586621680855044"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680855044"><span class="hs-identifier hs-var">tys</span></a></span></span><span>
</span><span id="line-437"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.Utils.Misc.html#debugIsOn"><span class="hs-identifier hs-var">debugIsOn</span></a></span><span>
</span><span id="line-438"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(TyCoVar -&gt; Bool) -&gt; [TyCoVar] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#all"><span class="hs-identifier hs-var">all</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar -&gt; Bool
</span><a href="GHC.Types.Var.html#isTyVar"><span class="hs-identifier hs-var">isTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680855045"><span class="hs-identifier hs-var">tyvars</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680855045"><span class="hs-identifier hs-var">tyvars</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCoVar] -&gt; [Type] -&gt; Bool
forall a b. [a] -&gt; [b] -&gt; Bool
</span><a href="GHC.Utils.Misc.html#equalLength"><span class="hs-operator hs-var">`equalLength`</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680855044"><span class="hs-identifier hs-var">tys</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-439"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TvSubstEnv
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;zipTyEnv&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TyCoVar] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680855045"><span class="hs-identifier hs-var">tyvars</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680855044"><span class="hs-identifier hs-var">tys</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-440"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-441"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">all</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">not</span><span> </span><span class="hs-operator">.</span><span> </span><span class="hs-identifier">isCoercionTy</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">tys</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-442"></span><span>    </span><span class="annot"><span class="annottext">[(TyCoVar, Type)] -&gt; TvSubstEnv
forall a. [(TyCoVar, a)] -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#mkVarEnv"><span class="hs-identifier hs-var">mkVarEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; [TyCoVar] -&gt; [Type] -&gt; [(TyCoVar, Type)]
forall a b. String -&gt; [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="GHC.Utils.Misc.html#zipEqual"><span class="hs-identifier hs-var">zipEqual</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;zipTyEnv&quot;</span></span><span> </span><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680855045"><span class="hs-identifier hs-var">tyvars</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680855044"><span class="hs-identifier hs-var">tys</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-443"></span><span>        </span><span class="hs-comment">-- There used to be a special case for when</span><span>
</span><span id="line-444"></span><span>        </span><span class="hs-comment">--      ty == TyVarTy tv</span><span>
</span><span id="line-445"></span><span>        </span><span class="hs-comment">-- (a not-uncommon case) in which case the substitution was dropped.</span><span>
</span><span id="line-446"></span><span>        </span><span class="hs-comment">-- But the type-tidier changes the print-name of a type variable without</span><span>
</span><span id="line-447"></span><span>        </span><span class="hs-comment">-- changing the unique, and that led to a bug.   Why?  Pre-tidying, we had</span><span>
</span><span id="line-448"></span><span>        </span><span class="hs-comment">-- a type {Foo t}, where Foo is a one-method class.  So Foo is really a newtype.</span><span>
</span><span id="line-449"></span><span>        </span><span class="hs-comment">-- And it happened that t was the type variable of the class.  Post-tiding,</span><span>
</span><span id="line-450"></span><span>        </span><span class="hs-comment">-- it got turned into {Foo t2}.  The ext-core printer expanded this using</span><span>
</span><span id="line-451"></span><span>        </span><span class="hs-comment">-- sourceTypeRep, but that said &quot;Oh, t == t2&quot; because they have the same unique,</span><span>
</span><span id="line-452"></span><span>        </span><span class="hs-comment">-- and so generated a rep type mentioning t not t2.</span><span>
</span><span id="line-453"></span><span>        </span><span class="hs-comment">--</span><span>
</span><span id="line-454"></span><span>        </span><span class="hs-comment">-- Simplest fix is to nuke the &quot;optimisation&quot;</span><span>
</span><span id="line-455"></span><span>
</span><span id="line-456"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#zipCoEnv"><span class="hs-identifier hs-type">zipCoEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html#HasDebugCallStack"><span class="hs-identifier hs-type">HasDebugCallStack</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#CoVar"><span class="hs-identifier hs-type">CoVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#CvSubstEnv"><span class="hs-identifier hs-type">CvSubstEnv</span></a></span><span>
</span><span id="line-457"></span><span id="zipCoEnv"><span class="annot"><span class="annottext">zipCoEnv :: HasDebugCallStack =&gt; [TyCoVar] -&gt; [Coercion] -&gt; CvSubstEnv
</span><a href="GHC.Core.TyCo.Subst.html#zipCoEnv"><span class="hs-identifier hs-var hs-var">zipCoEnv</span></a></span></span><span> </span><span id="local-6989586621680855030"><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680855030"><span class="hs-identifier hs-var">cvs</span></a></span></span><span> </span><span id="local-6989586621680855029"><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680855029"><span class="hs-identifier hs-var">cos</span></a></span></span><span>
</span><span id="line-458"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.Utils.Misc.html#debugIsOn"><span class="hs-identifier hs-var">debugIsOn</span></a></span><span>
</span><span id="line-459"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(TyCoVar -&gt; Bool) -&gt; [TyCoVar] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#all"><span class="hs-identifier hs-var">all</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar -&gt; Bool
</span><a href="GHC.Types.Var.html#isCoVar"><span class="hs-identifier hs-var">isCoVar</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680855030"><span class="hs-identifier hs-var">cvs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-460"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; CvSubstEnv
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;zipCoEnv&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TyCoVar] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680855030"><span class="hs-identifier hs-var">cvs</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[Coercion] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680855029"><span class="hs-identifier hs-var">cos</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-461"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-462"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(TyCoVar, Coercion)] -&gt; CvSubstEnv
forall a. [(TyCoVar, a)] -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#mkVarEnv"><span class="hs-identifier hs-var">mkVarEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; [TyCoVar] -&gt; [Coercion] -&gt; [(TyCoVar, Coercion)]
forall a b. String -&gt; [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="GHC.Utils.Misc.html#zipEqual"><span class="hs-identifier hs-var">zipEqual</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;zipCoEnv&quot;</span></span><span> </span><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680855030"><span class="hs-identifier hs-var">cvs</span></a></span><span> </span><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680855029"><span class="hs-identifier hs-var">cos</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-463"></span><span>
</span><span id="line-464"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621680855025"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-465"></span><span>  </span><span id="local-6989586621680855017"><span class="annot"><span class="annottext">ppr :: TCvSubst -&gt; SDoc
</span><a href="#local-6989586621680855017"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span id="local-6989586621680855016"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855016"><span class="hs-identifier hs-var">ins</span></a></span></span><span> </span><span id="local-6989586621680855015"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855015"><span class="hs-identifier hs-var">tenv</span></a></span></span><span> </span><span id="local-6989586621680855014"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855014"><span class="hs-identifier hs-var">cenv</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-466"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#brackets"><span class="hs-identifier hs-var">brackets</span></a></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; SDoc) -&gt; SDoc -&gt; SDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#sep"><span class="hs-identifier hs-var">sep</span></a></span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;TCvSubst&quot;</span></span><span class="hs-special">,</span><span>
</span><span id="line-467"></span><span>                      </span><span class="annot"><span class="annottext">Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#nest"><span class="hs-identifier hs-var">nest</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;In scope:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855016"><span class="hs-identifier hs-var">ins</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-468"></span><span>                      </span><span class="annot"><span class="annottext">Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#nest"><span class="hs-identifier hs-var">nest</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Type env:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680855015"><span class="hs-identifier hs-var">tenv</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-469"></span><span>                      </span><span class="annot"><span class="annottext">Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#nest"><span class="hs-identifier hs-var">nest</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Co env:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680855014"><span class="hs-identifier hs-var">cenv</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-470"></span><span>
</span><span id="line-471"></span><span class="hs-comment">{-
%************************************************************************
%*                                                                      *
                Performing type or kind substitutions
%*                                                                      *
%************************************************************************

Note [Sym and ForAllCo]
~~~~~~~~~~~~~~~~~~~~~~~
In OptCoercion, we try to push &quot;sym&quot; out to the leaves of a coercion. But,
how do we push sym into a ForAllCo? It's a little ugly.

Here is the typing rule:

h : k1 ~# k2
(tv : k1) |- g : ty1 ~# ty2
----------------------------
ForAllCo tv h g : (ForAllTy (tv : k1) ty1) ~#
                  (ForAllTy (tv : k2) (ty2[tv |-&gt; tv |&gt; sym h]))

Here is what we want:

ForAllCo tv h' g' : (ForAllTy (tv : k2) (ty2[tv |-&gt; tv |&gt; sym h])) ~#
                    (ForAllTy (tv : k1) ty1)


Because the kinds of the type variables to the right of the colon are the kinds
coerced by h', we know (h' : k2 ~# k1). Thus, (h' = sym h).

Now, we can rewrite ty1 to be (ty1[tv |-&gt; tv |&gt; sym h' |&gt; h']). We thus want

ForAllCo tv h' g' :
  (ForAllTy (tv : k2) (ty2[tv |-&gt; tv |&gt; h'])) ~#
  (ForAllTy (tv : k1) (ty1[tv |-&gt; tv |&gt; h'][tv |-&gt; tv |&gt; sym h']))

We thus see that we want

g' : ty2[tv |-&gt; tv |&gt; h'] ~# ty1[tv |-&gt; tv |&gt; h']

and thus g' = sym (g[tv |-&gt; tv |&gt; h']).

Putting it all together, we get this:

sym (ForAllCo tv h g)
==&gt;
ForAllCo tv (sym h) (sym g[tv |-&gt; tv |&gt; sym h])

Note [Substituting in a coercion hole]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It seems highly suspicious to be substituting in a coercion that still
has coercion holes. Yet, this can happen in a situation like this:

  f :: forall k. k :~: Type -&gt; ()
  f Refl = let x :: forall (a :: k). [a] -&gt; ...
               x = ...

When we check x's type signature, we require that k ~ Type. We indeed
know this due to the Refl pattern match, but the eager unifier can't
make use of givens. So, when we're done looking at x's type, a coercion
hole will remain. Then, when we're checking x's definition, we skolemise
x's type (in order to, e.g., bring the scoped type variable `a` into scope).
This requires performing a substitution for the fresh skolem variables.

This substitution needs to affect the kind of the coercion hole, too --
otherwise, the kind will have an out-of-scope variable in it. More problematically
in practice (we won't actually notice the out-of-scope variable ever), skolems
in the kind might have too high a level, triggering a failure to uphold the
invariant that no free variables in a type have a higher level than the
ambient level in the type checker. In the event of having free variables in the
hole's kind, I'm pretty sure we'll always have an erroneous program, so we
don't need to worry what will happen when the hole gets filled in. After all,
a hole relating a locally-bound type variable will be unable to be solved. This
is why it's OK not to look through the IORef of a coercion hole during
substitution.

-}</span><span>
</span><span id="line-547"></span><span>
</span><span id="line-548"></span><span class="hs-comment">-- | Type substitution, see 'zipTvSubst'</span><span>
</span><span id="line-549"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTyWith"><span class="hs-identifier hs-type">substTyWith</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Stack.Types.html#HasCallStack"><span class="hs-identifier hs-type">HasCallStack</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-550"></span><span class="hs-comment">-- Works only if the domain of the substitution is a</span><span>
</span><span id="line-551"></span><span class="hs-comment">-- superset of the type being substituted into</span><span>
</span><span id="line-552"></span><span id="substTyWith"><span class="annot"><span class="annottext">substTyWith :: HasCallStack =&gt; [TyCoVar] -&gt; [Type] -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTyWith"><span class="hs-identifier hs-var hs-var">substTyWith</span></a></span></span><span> </span><span id="local-6989586621680855006"><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680855006"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621680855005"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680855005"><span class="hs-identifier hs-var">tys</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-pragma">{-#SCC</span><span> </span><span class="hs-pragma">&quot;substTyWith&quot;</span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-553"></span><span>                      </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">tvs</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">equalLength</span><span class="hs-special">`</span><span> </span><span class="hs-identifier">tys</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-554"></span><span>                      </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; Type -&gt; Type
TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTy"><span class="hs-identifier hs-var">substTy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TyCoVar] -&gt; [Type] -&gt; TCvSubst
HasDebugCallStack =&gt; [TyCoVar] -&gt; [Type] -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#zipTvSubst"><span class="hs-identifier hs-var">zipTvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680855006"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680855005"><span class="hs-identifier hs-var">tys</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-555"></span><span>
</span><span id="line-556"></span><span class="hs-comment">-- | Type substitution, see 'zipTvSubst'. Disables sanity checks.</span><span>
</span><span id="line-557"></span><span class="hs-comment">-- The problems that the sanity checks in substTy catch are described in</span><span>
</span><span id="line-558"></span><span class="hs-comment">-- Note [The substitution invariant].</span><span>
</span><span id="line-559"></span><span class="hs-comment">-- The goal of #11371 is to migrate all the calls of substTyUnchecked to</span><span>
</span><span id="line-560"></span><span class="hs-comment">-- substTy and remove this function. Please don't use in new code.</span><span>
</span><span id="line-561"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTyWithUnchecked"><span class="hs-identifier hs-type">substTyWithUnchecked</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-562"></span><span id="substTyWithUnchecked"><span class="annot"><span class="annottext">substTyWithUnchecked :: [TyCoVar] -&gt; [Type] -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTyWithUnchecked"><span class="hs-identifier hs-var hs-var">substTyWithUnchecked</span></a></span></span><span> </span><span id="local-6989586621680855004"><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680855004"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621680855003"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680855003"><span class="hs-identifier hs-var">tys</span></a></span></span><span>
</span><span id="line-563"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">tvs</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">equalLength</span><span class="hs-special">`</span><span> </span><span class="hs-identifier">tys</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-564"></span><span>    </span><span class="annot"><span class="annottext">TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTyUnchecked"><span class="hs-identifier hs-var">substTyUnchecked</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TyCoVar] -&gt; [Type] -&gt; TCvSubst
HasDebugCallStack =&gt; [TyCoVar] -&gt; [Type] -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#zipTvSubst"><span class="hs-identifier hs-var">zipTvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680855004"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680855003"><span class="hs-identifier hs-var">tys</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-565"></span><span>
</span><span id="line-566"></span><span class="hs-comment">-- | Substitute tyvars within a type using a known 'InScopeSet'.</span><span>
</span><span id="line-567"></span><span class="hs-comment">-- Pre-condition: the 'in_scope' set should satisfy Note [The substitution</span><span>
</span><span id="line-568"></span><span class="hs-comment">-- invariant]; specifically it should include the free vars of 'tys',</span><span>
</span><span id="line-569"></span><span class="hs-comment">-- and of 'ty' minus the domain of the subst.</span><span>
</span><span id="line-570"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTyWithInScope"><span class="hs-identifier hs-type">substTyWithInScope</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#InScopeSet"><span class="hs-identifier hs-type">InScopeSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-571"></span><span id="substTyWithInScope"><span class="annot"><span class="annottext">substTyWithInScope :: InScopeSet -&gt; [TyCoVar] -&gt; [Type] -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTyWithInScope"><span class="hs-identifier hs-var hs-var">substTyWithInScope</span></a></span></span><span> </span><span id="local-6989586621680855002"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855002"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680855001"><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680855001"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621680855000"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680855000"><span class="hs-identifier hs-var">tys</span></a></span></span><span> </span><span id="local-6989586621680854999"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854999"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-572"></span><span>  </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">tvs</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">equalLength</span><span class="hs-special">`</span><span> </span><span class="hs-identifier">tys</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-573"></span><span>  </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; Type -&gt; Type
TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTy"><span class="hs-identifier hs-var">substTy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet -&gt; TvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#mkTvSubst"><span class="hs-identifier hs-var">mkTvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680855002"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854998"><span class="hs-identifier hs-var">tenv</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854999"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-574"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621680854998"><span class="annot"><span class="annottext">tenv :: TvSubstEnv
</span><a href="#local-6989586621680854998"><span class="hs-identifier hs-var hs-var">tenv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TyCoVar] -&gt; [Type] -&gt; TvSubstEnv
HasDebugCallStack =&gt; [TyCoVar] -&gt; [Type] -&gt; TvSubstEnv
</span><a href="GHC.Core.TyCo.Subst.html#zipTyEnv"><span class="hs-identifier hs-var">zipTyEnv</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680855001"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680855000"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-575"></span><span>
</span><span id="line-576"></span><span class="hs-comment">-- | Coercion substitution, see 'zipTvSubst'</span><span>
</span><span id="line-577"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substCoWith"><span class="hs-identifier hs-type">substCoWith</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Stack.Types.html#HasCallStack"><span class="hs-identifier hs-type">HasCallStack</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span>
</span><span id="line-578"></span><span id="substCoWith"><span class="annot"><span class="annottext">substCoWith :: HasCallStack =&gt; [TyCoVar] -&gt; [Type] -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.TyCo.Subst.html#substCoWith"><span class="hs-identifier hs-var hs-var">substCoWith</span></a></span></span><span> </span><span id="local-6989586621680854992"><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680854992"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621680854991"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854991"><span class="hs-identifier hs-var">tys</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">tvs</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">equalLength</span><span class="hs-special">`</span><span> </span><span class="hs-identifier">tys</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-579"></span><span>                      </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; Coercion -&gt; Coercion
TCvSubst -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.TyCo.Subst.html#substCo"><span class="hs-identifier hs-var">substCo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TyCoVar] -&gt; [Type] -&gt; TCvSubst
HasDebugCallStack =&gt; [TyCoVar] -&gt; [Type] -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#zipTvSubst"><span class="hs-identifier hs-var">zipTvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680854992"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854991"><span class="hs-identifier hs-var">tys</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-580"></span><span>
</span><span id="line-581"></span><span class="hs-comment">-- | Coercion substitution, see 'zipTvSubst'. Disables sanity checks.</span><span>
</span><span id="line-582"></span><span class="hs-comment">-- The problems that the sanity checks in substCo catch are described in</span><span>
</span><span id="line-583"></span><span class="hs-comment">-- Note [The substitution invariant].</span><span>
</span><span id="line-584"></span><span class="hs-comment">-- The goal of #11371 is to migrate all the calls of substCoUnchecked to</span><span>
</span><span id="line-585"></span><span class="hs-comment">-- substCo and remove this function. Please don't use in new code.</span><span>
</span><span id="line-586"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substCoWithUnchecked"><span class="hs-identifier hs-type">substCoWithUnchecked</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span>
</span><span id="line-587"></span><span id="substCoWithUnchecked"><span class="annot"><span class="annottext">substCoWithUnchecked :: [TyCoVar] -&gt; [Type] -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.TyCo.Subst.html#substCoWithUnchecked"><span class="hs-identifier hs-var hs-var">substCoWithUnchecked</span></a></span></span><span> </span><span id="local-6989586621680854990"><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680854990"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621680854989"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854989"><span class="hs-identifier hs-var">tys</span></a></span></span><span>
</span><span id="line-588"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">tvs</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">equalLength</span><span class="hs-special">`</span><span> </span><span class="hs-identifier">tys</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-589"></span><span>    </span><span class="annot"><span class="annottext">TCvSubst -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.TyCo.Subst.html#substCoUnchecked"><span class="hs-identifier hs-var">substCoUnchecked</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TyCoVar] -&gt; [Type] -&gt; TCvSubst
HasDebugCallStack =&gt; [TyCoVar] -&gt; [Type] -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#zipTvSubst"><span class="hs-identifier hs-var">zipTvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680854990"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854989"><span class="hs-identifier hs-var">tys</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-590"></span><span>
</span><span id="line-591"></span><span>
</span><span id="line-592"></span><span>
</span><span id="line-593"></span><span class="hs-comment">-- | Substitute covars within a type</span><span>
</span><span id="line-594"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTyWithCoVars"><span class="hs-identifier hs-type">substTyWithCoVars</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#CoVar"><span class="hs-identifier hs-type">CoVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-595"></span><span id="substTyWithCoVars"><span class="annot"><span class="annottext">substTyWithCoVars :: [TyCoVar] -&gt; [Coercion] -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTyWithCoVars"><span class="hs-identifier hs-var hs-var">substTyWithCoVars</span></a></span></span><span> </span><span id="local-6989586621680854988"><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680854988"><span class="hs-identifier hs-var">cvs</span></a></span></span><span> </span><span id="local-6989586621680854987"><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680854987"><span class="hs-identifier hs-var">cos</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; Type -&gt; Type
TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTy"><span class="hs-identifier hs-var">substTy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TyCoVar] -&gt; [Coercion] -&gt; TCvSubst
HasDebugCallStack =&gt; [TyCoVar] -&gt; [Coercion] -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#zipCvSubst"><span class="hs-identifier hs-var">zipCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680854988"><span class="hs-identifier hs-var">cvs</span></a></span><span> </span><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680854987"><span class="hs-identifier hs-var">cos</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-596"></span><span>
</span><span id="line-597"></span><span class="hs-comment">-- | Type substitution, see 'zipTvSubst'</span><span>
</span><span id="line-598"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTysWith"><span class="hs-identifier hs-type">substTysWith</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-599"></span><span id="substTysWith"><span class="annot"><span class="annottext">substTysWith :: [TyCoVar] -&gt; [Type] -&gt; [Type] -&gt; [Type]
</span><a href="GHC.Core.TyCo.Subst.html#substTysWith"><span class="hs-identifier hs-var hs-var">substTysWith</span></a></span></span><span> </span><span id="local-6989586621680854986"><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680854986"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621680854985"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854985"><span class="hs-identifier hs-var">tys</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">tvs</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">equalLength</span><span class="hs-special">`</span><span> </span><span class="hs-identifier">tys</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-600"></span><span>                       </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; [Type] -&gt; [Type]
TCvSubst -&gt; [Type] -&gt; [Type]
</span><a href="GHC.Core.TyCo.Subst.html#substTys"><span class="hs-identifier hs-var">substTys</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TyCoVar] -&gt; [Type] -&gt; TCvSubst
HasDebugCallStack =&gt; [TyCoVar] -&gt; [Type] -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#zipTvSubst"><span class="hs-identifier hs-var">zipTvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680854986"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854985"><span class="hs-identifier hs-var">tys</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-601"></span><span>
</span><span id="line-602"></span><span class="hs-comment">-- | Type substitution, see 'zipTvSubst'</span><span>
</span><span id="line-603"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTysWithCoVars"><span class="hs-identifier hs-type">substTysWithCoVars</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#CoVar"><span class="hs-identifier hs-type">CoVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-604"></span><span id="substTysWithCoVars"><span class="annot"><span class="annottext">substTysWithCoVars :: [TyCoVar] -&gt; [Coercion] -&gt; [Type] -&gt; [Type]
</span><a href="GHC.Core.TyCo.Subst.html#substTysWithCoVars"><span class="hs-identifier hs-var hs-var">substTysWithCoVars</span></a></span></span><span> </span><span id="local-6989586621680854984"><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680854984"><span class="hs-identifier hs-var">cvs</span></a></span></span><span> </span><span id="local-6989586621680854983"><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680854983"><span class="hs-identifier hs-var">cos</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">cvs</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">equalLength</span><span class="hs-special">`</span><span> </span><span class="hs-identifier">cos</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-605"></span><span>                             </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; [Type] -&gt; [Type]
TCvSubst -&gt; [Type] -&gt; [Type]
</span><a href="GHC.Core.TyCo.Subst.html#substTys"><span class="hs-identifier hs-var">substTys</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TyCoVar] -&gt; [Coercion] -&gt; TCvSubst
HasDebugCallStack =&gt; [TyCoVar] -&gt; [Coercion] -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#zipCvSubst"><span class="hs-identifier hs-var">zipCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680854984"><span class="hs-identifier hs-var">cvs</span></a></span><span> </span><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680854983"><span class="hs-identifier hs-var">cos</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-606"></span><span>
</span><span id="line-607"></span><span class="hs-comment">-- | Substitute within a 'Type' after adding the free variables of the type</span><span>
</span><span id="line-608"></span><span class="hs-comment">-- to the in-scope set. This is useful for the case when the free variables</span><span>
</span><span id="line-609"></span><span class="hs-comment">-- aren't already in the in-scope set or easily available.</span><span>
</span><span id="line-610"></span><span class="hs-comment">-- See also Note [The substitution invariant].</span><span>
</span><span id="line-611"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTyAddInScope"><span class="hs-identifier hs-type">substTyAddInScope</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-612"></span><span id="substTyAddInScope"><span class="annot"><span class="annottext">substTyAddInScope :: TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTyAddInScope"><span class="hs-identifier hs-var hs-var">substTyAddInScope</span></a></span></span><span> </span><span id="local-6989586621680854982"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854982"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680854981"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854981"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-613"></span><span>  </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; Type -&gt; Type
TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTy"><span class="hs-identifier hs-var">substTy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst -&gt; VarSet -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#extendTCvInScopeSet"><span class="hs-identifier hs-var">extendTCvInScopeSet</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854982"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">(VarSet -&gt; TCvSubst) -&gt; VarSet -&gt; TCvSubst
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfType"><span class="hs-identifier hs-var">tyCoVarsOfType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854981"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854981"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-614"></span><span>
</span><span id="line-615"></span><span class="hs-comment">-- | When calling `substTy` it should be the case that the in-scope set in</span><span>
</span><span id="line-616"></span><span class="hs-comment">-- the substitution is a superset of the free vars of the range of the</span><span>
</span><span id="line-617"></span><span class="hs-comment">-- substitution.</span><span>
</span><span id="line-618"></span><span class="hs-comment">-- See also Note [The substitution invariant].</span><span>
</span><span id="line-619"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#isValidTCvSubst"><span class="hs-identifier hs-type">isValidTCvSubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-620"></span><span id="isValidTCvSubst"><span class="annot"><span class="annottext">isValidTCvSubst :: TCvSubst -&gt; Bool
</span><a href="GHC.Core.TyCo.Subst.html#isValidTCvSubst"><span class="hs-identifier hs-var hs-var">isValidTCvSubst</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span id="local-6989586621680854980"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680854980"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680854979"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854979"><span class="hs-identifier hs-var">tenv</span></a></span></span><span> </span><span id="local-6989586621680854978"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680854978"><span class="hs-identifier hs-var">cenv</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-621"></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680854977"><span class="hs-identifier hs-var">tenvFVs</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; InScopeSet -&gt; Bool
</span><a href="GHC.Types.Var.Env.html#varSetInScope"><span class="hs-operator hs-var">`varSetInScope`</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680854980"><span class="hs-identifier hs-var">in_scope</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span>
</span><span id="line-622"></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680854975"><span class="hs-identifier hs-var">cenvFVs</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; InScopeSet -&gt; Bool
</span><a href="GHC.Types.Var.Env.html#varSetInScope"><span class="hs-operator hs-var">`varSetInScope`</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680854980"><span class="hs-identifier hs-var">in_scope</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-623"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-624"></span><span>  </span><span id="local-6989586621680854977"><span class="annot"><span class="annottext">tenvFVs :: VarSet
</span><a href="#local-6989586621680854977"><span class="hs-identifier hs-var hs-var">tenvFVs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#shallowTyCoVarsOfTyVarEnv"><span class="hs-identifier hs-var">shallowTyCoVarsOfTyVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854979"><span class="hs-identifier hs-var">tenv</span></a></span><span>
</span><span id="line-625"></span><span>  </span><span id="local-6989586621680854975"><span class="annot"><span class="annottext">cenvFVs :: VarSet
</span><a href="#local-6989586621680854975"><span class="hs-identifier hs-var hs-var">cenvFVs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#shallowTyCoVarsOfCoVarEnv"><span class="hs-identifier hs-var">shallowTyCoVarsOfCoVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680854978"><span class="hs-identifier hs-var">cenv</span></a></span><span>
</span><span id="line-626"></span><span>
</span><span id="line-627"></span><span class="hs-comment">-- | This checks if the substitution satisfies the invariant from</span><span>
</span><span id="line-628"></span><span class="hs-comment">-- Note [The substitution invariant].</span><span>
</span><span id="line-629"></span><span id="local-6989586621680855424"><span class="annot"><a href="GHC.Core.TyCo.Subst.html#checkValidSubst"><span class="hs-identifier hs-type">checkValidSubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Stack.Types.html#HasCallStack"><span class="hs-identifier hs-type">HasCallStack</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680855424"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680855424"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-630"></span><span id="checkValidSubst"><span class="annot"><span class="annottext">checkValidSubst :: forall a.
HasCallStack =&gt;
TCvSubst -&gt; [Type] -&gt; [Coercion] -&gt; a -&gt; a
</span><a href="GHC.Core.TyCo.Subst.html#checkValidSubst"><span class="hs-identifier hs-var hs-var">checkValidSubst</span></a></span></span><span> </span><span id="local-6989586621680854954"><span class="annot"><span class="annottext">subst :: TCvSubst
</span><a href="#local-6989586621680854954"><span class="hs-identifier hs-var">subst</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span id="local-6989586621680854953"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680854953"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680854952"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854952"><span class="hs-identifier hs-var">tenv</span></a></span></span><span> </span><span id="local-6989586621680854951"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680854951"><span class="hs-identifier hs-var">cenv</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680854950"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854950"><span class="hs-identifier hs-var">tys</span></a></span></span><span> </span><span id="local-6989586621680854949"><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680854949"><span class="hs-identifier hs-var">cos</span></a></span></span><span> </span><span id="local-6989586621680854948"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680854948"><span class="hs-identifier hs-var">a</span></a></span></span><span>
</span><span id="line-631"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT2</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isValidTCvSubst</span><span> </span><span class="hs-identifier">subst</span><span class="hs-special">,</span><span>
</span><span id="line-632"></span><span>             </span><span class="hs-identifier">text</span><span> </span><span class="hs-string">&quot;in_scope&quot;</span><span> </span><span class="hs-operator">&lt;+&gt;</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">in_scope</span><span> </span><span class="hs-operator">$$</span><span>
</span><span id="line-633"></span><span>             </span><span class="hs-identifier">text</span><span> </span><span class="hs-string">&quot;tenv&quot;</span><span> </span><span class="hs-operator">&lt;+&gt;</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">tenv</span><span> </span><span class="hs-operator">$$</span><span>
</span><span id="line-634"></span><span>             </span><span class="hs-identifier">text</span><span> </span><span class="hs-string">&quot;tenvFVs&quot;</span><span> </span><span class="hs-operator">&lt;+&gt;</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">shallowTyCoVarsOfTyVarEnv</span><span> </span><span class="hs-identifier">tenv</span><span class="hs-special">)</span><span> </span><span class="hs-operator">$$</span><span>
</span><span id="line-635"></span><span>             </span><span class="hs-identifier">text</span><span> </span><span class="hs-string">&quot;cenv&quot;</span><span> </span><span class="hs-operator">&lt;+&gt;</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">cenv</span><span> </span><span class="hs-operator">$$</span><span>
</span><span id="line-636"></span><span>             </span><span class="hs-identifier">text</span><span> </span><span class="hs-string">&quot;cenvFVs&quot;</span><span> </span><span class="hs-operator">&lt;+&gt;</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">shallowTyCoVarsOfCoVarEnv</span><span> </span><span class="hs-identifier">cenv</span><span class="hs-special">)</span><span> </span><span class="hs-operator">$$</span><span>
</span><span id="line-637"></span><span>             </span><span class="hs-identifier">text</span><span> </span><span class="hs-string">&quot;tys&quot;</span><span> </span><span class="hs-operator">&lt;+&gt;</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">tys</span><span> </span><span class="hs-operator">$$</span><span>
</span><span id="line-638"></span><span>             </span><span class="hs-identifier">text</span><span> </span><span class="hs-string">&quot;cos&quot;</span><span> </span><span class="hs-operator">&lt;+&gt;</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">cos</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-639"></span><span>    </span><span class="hs-identifier">ASSERT2</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">tysCosFVsInScope</span><span class="hs-special">,</span><span>
</span><span id="line-640"></span><span>             </span><span class="hs-identifier">text</span><span> </span><span class="hs-string">&quot;in_scope&quot;</span><span> </span><span class="hs-operator">&lt;+&gt;</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">in_scope</span><span> </span><span class="hs-operator">$$</span><span>
</span><span id="line-641"></span><span>             </span><span class="hs-identifier">text</span><span> </span><span class="hs-string">&quot;tenv&quot;</span><span> </span><span class="hs-operator">&lt;+&gt;</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">tenv</span><span> </span><span class="hs-operator">$$</span><span>
</span><span id="line-642"></span><span>             </span><span class="hs-identifier">text</span><span> </span><span class="hs-string">&quot;cenv&quot;</span><span> </span><span class="hs-operator">&lt;+&gt;</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">cenv</span><span> </span><span class="hs-operator">$$</span><span>
</span><span id="line-643"></span><span>             </span><span class="hs-identifier">text</span><span> </span><span class="hs-string">&quot;tys&quot;</span><span> </span><span class="hs-operator">&lt;+&gt;</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">tys</span><span> </span><span class="hs-operator">$$</span><span>
</span><span id="line-644"></span><span>             </span><span class="hs-identifier">text</span><span> </span><span class="hs-string">&quot;cos&quot;</span><span> </span><span class="hs-operator">&lt;+&gt;</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">cos</span><span> </span><span class="hs-operator">$$</span><span>
</span><span id="line-645"></span><span>             </span><span class="hs-identifier">text</span><span> </span><span class="hs-string">&quot;needInScope&quot;</span><span> </span><span class="hs-operator">&lt;+&gt;</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">needInScope</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-646"></span><span>    </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680854948"><span class="hs-identifier hs-var">a</span></a></span><span>
</span><span id="line-647"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-648"></span><span>  </span><span id="local-6989586621680854945"><span class="annot"><span class="annottext">substDomain :: [Unique]
</span><a href="#local-6989586621680854945"><span class="hs-identifier hs-var hs-var">substDomain</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv -&gt; [Unique]
forall key elt. UniqFM key elt -&gt; [Unique]
</span><a href="GHC.Types.Unique.FM.html#nonDetKeysUFM"><span class="hs-identifier hs-var">nonDetKeysUFM</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854952"><span class="hs-identifier hs-var">tenv</span></a></span><span> </span><span class="annot"><span class="annottext">[Unique] -&gt; [Unique] -&gt; [Unique]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv -&gt; [Unique]
forall key elt. UniqFM key elt -&gt; [Unique]
</span><a href="GHC.Types.Unique.FM.html#nonDetKeysUFM"><span class="hs-identifier hs-var">nonDetKeysUFM</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680854951"><span class="hs-identifier hs-var">cenv</span></a></span><span>
</span><span id="line-649"></span><span>    </span><span class="hs-comment">-- It's OK to use nonDetKeysUFM here, because we only use this list to</span><span>
</span><span id="line-650"></span><span>    </span><span class="hs-comment">-- remove some elements from a set</span><span>
</span><span id="line-651"></span><span>  </span><span id="local-6989586621680854946"><span class="annot"><span class="annottext">needInScope :: VarSet
</span><a href="#local-6989586621680854946"><span class="hs-identifier hs-var hs-var">needInScope</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Type] -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#shallowTyCoVarsOfTypes"><span class="hs-identifier hs-var">shallowTyCoVarsOfTypes</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854950"><span class="hs-identifier hs-var">tys</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#unionVarSet"><span class="hs-operator hs-var">`unionVarSet`</span></a></span><span>
</span><span id="line-652"></span><span>                 </span><span class="annot"><span class="annottext">[Coercion] -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#shallowTyCoVarsOfCos"><span class="hs-identifier hs-var">shallowTyCoVarsOfCos</span></a></span><span> </span><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680854949"><span class="hs-identifier hs-var">cos</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-653"></span><span>                </span><span class="annot"><span class="annottext">VarSet -&gt; [Unique] -&gt; VarSet
forall a. UniqSet a -&gt; [Unique] -&gt; UniqSet a
</span><a href="GHC.Types.Unique.Set.html#delListFromUniqSet_Directly"><span class="hs-operator hs-var">`delListFromUniqSet_Directly`</span></a></span><span> </span><span class="annot"><span class="annottext">[Unique]
</span><a href="#local-6989586621680854945"><span class="hs-identifier hs-var">substDomain</span></a></span><span>
</span><span id="line-654"></span><span>  </span><span id="local-6989586621680854947"><span class="annot"><span class="annottext">tysCosFVsInScope :: Bool
</span><a href="#local-6989586621680854947"><span class="hs-identifier hs-var hs-var">tysCosFVsInScope</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680854946"><span class="hs-identifier hs-var">needInScope</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; InScopeSet -&gt; Bool
</span><a href="GHC.Types.Var.Env.html#varSetInScope"><span class="hs-operator hs-var">`varSetInScope`</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680854953"><span class="hs-identifier hs-var">in_scope</span></a></span><span>
</span><span id="line-655"></span><span>
</span><span id="line-656"></span><span>
</span><span id="line-657"></span><span class="hs-comment">-- | Substitute within a 'Type'</span><span>
</span><span id="line-658"></span><span class="hs-comment">-- The substitution has to satisfy the invariants described in</span><span>
</span><span id="line-659"></span><span class="hs-comment">-- Note [The substitution invariant].</span><span>
</span><span id="line-660"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTy"><span class="hs-identifier hs-type">substTy</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Stack.Types.html#HasCallStack"><span class="hs-identifier hs-type">HasCallStack</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-661"></span><span id="substTy"><span class="annot"><span class="annottext">substTy :: HasCallStack =&gt; TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTy"><span class="hs-identifier hs-var hs-var">substTy</span></a></span></span><span> </span><span id="local-6989586621680854939"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854939"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680854938"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854938"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-662"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; Bool
</span><a href="GHC.Core.TyCo.Subst.html#isEmptyTCvSubst"><span class="hs-identifier hs-var">isEmptyTCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854939"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854938"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-663"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; [Type] -&gt; [Coercion] -&gt; Type -&gt; Type
forall a.
HasCallStack =&gt;
TCvSubst -&gt; [Type] -&gt; [Coercion] -&gt; a -&gt; a
</span><a href="GHC.Core.TyCo.Subst.html#checkValidSubst"><span class="hs-identifier hs-var">checkValidSubst</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854939"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854938"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">(Type -&gt; Type) -&gt; Type -&gt; Type
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-664"></span><span>                            </span><span class="annot"><span class="annottext">TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#subst_ty"><span class="hs-identifier hs-var">subst_ty</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854939"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854938"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-665"></span><span>
</span><span id="line-666"></span><span class="hs-comment">-- | Substitute within a 'Type' disabling the sanity checks.</span><span>
</span><span id="line-667"></span><span class="hs-comment">-- The problems that the sanity checks in substTy catch are described in</span><span>
</span><span id="line-668"></span><span class="hs-comment">-- Note [The substitution invariant].</span><span>
</span><span id="line-669"></span><span class="hs-comment">-- The goal of #11371 is to migrate all the calls of substTyUnchecked to</span><span>
</span><span id="line-670"></span><span class="hs-comment">-- substTy and remove this function. Please don't use in new code.</span><span>
</span><span id="line-671"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTyUnchecked"><span class="hs-identifier hs-type">substTyUnchecked</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-672"></span><span id="substTyUnchecked"><span class="annot"><span class="annottext">substTyUnchecked :: TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTyUnchecked"><span class="hs-identifier hs-var hs-var">substTyUnchecked</span></a></span></span><span> </span><span id="local-6989586621680854936"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854936"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680854935"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854935"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-673"></span><span>                 </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; Bool
</span><a href="GHC.Core.TyCo.Subst.html#isEmptyTCvSubst"><span class="hs-identifier hs-var">isEmptyTCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854936"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854935"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-674"></span><span>                 </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#subst_ty"><span class="hs-identifier hs-var">subst_ty</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854936"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854935"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-675"></span><span>
</span><span id="line-676"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substScaledTy"><span class="hs-identifier hs-type">substScaledTy</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Stack.Types.html#HasCallStack"><span class="hs-identifier hs-type">HasCallStack</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-type">Scaled</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-type">Scaled</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-677"></span><span id="substScaledTy"><span class="annot"><span class="annottext">substScaledTy :: HasCallStack =&gt; TCvSubst -&gt; Scaled Type -&gt; Scaled Type
</span><a href="GHC.Core.TyCo.Subst.html#substScaledTy"><span class="hs-identifier hs-var hs-var">substScaledTy</span></a></span></span><span> </span><span id="local-6989586621680854931"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854931"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680854930"><span class="annot"><span class="annottext">Scaled Type
</span><a href="#local-6989586621680854930"><span class="hs-identifier hs-var">scaled_ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Type -&gt; Type) -&gt; Scaled Type -&gt; Scaled Type
</span><a href="GHC.Core.TyCo.Rep.html#mapScaledType"><span class="hs-identifier hs-var">mapScaledType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; Type -&gt; Type
TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTy"><span class="hs-identifier hs-var">substTy</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854931"><span class="hs-identifier hs-var">subst</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Scaled Type
</span><a href="#local-6989586621680854930"><span class="hs-identifier hs-var">scaled_ty</span></a></span><span>
</span><span id="line-678"></span><span>
</span><span id="line-679"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substScaledTyUnchecked"><span class="hs-identifier hs-type">substScaledTyUnchecked</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Stack.Types.html#HasCallStack"><span class="hs-identifier hs-type">HasCallStack</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-type">Scaled</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-type">Scaled</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-680"></span><span id="substScaledTyUnchecked"><span class="annot"><span class="annottext">substScaledTyUnchecked :: HasCallStack =&gt; TCvSubst -&gt; Scaled Type -&gt; Scaled Type
</span><a href="GHC.Core.TyCo.Subst.html#substScaledTyUnchecked"><span class="hs-identifier hs-var hs-var">substScaledTyUnchecked</span></a></span></span><span> </span><span id="local-6989586621680854927"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854927"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680854926"><span class="annot"><span class="annottext">Scaled Type
</span><a href="#local-6989586621680854926"><span class="hs-identifier hs-var">scaled_ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Type -&gt; Type) -&gt; Scaled Type -&gt; Scaled Type
</span><a href="GHC.Core.TyCo.Rep.html#mapScaledType"><span class="hs-identifier hs-var">mapScaledType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTyUnchecked"><span class="hs-identifier hs-var">substTyUnchecked</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854927"><span class="hs-identifier hs-var">subst</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Scaled Type
</span><a href="#local-6989586621680854926"><span class="hs-identifier hs-var">scaled_ty</span></a></span><span>
</span><span id="line-681"></span><span>
</span><span id="line-682"></span><span class="hs-comment">-- | Substitute within several 'Type's</span><span>
</span><span id="line-683"></span><span class="hs-comment">-- The substitution has to satisfy the invariants described in</span><span>
</span><span id="line-684"></span><span class="hs-comment">-- Note [The substitution invariant].</span><span>
</span><span id="line-685"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTys"><span class="hs-identifier hs-type">substTys</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Stack.Types.html#HasCallStack"><span class="hs-identifier hs-type">HasCallStack</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-686"></span><span id="substTys"><span class="annot"><span class="annottext">substTys :: HasCallStack =&gt; TCvSubst -&gt; [Type] -&gt; [Type]
</span><a href="GHC.Core.TyCo.Subst.html#substTys"><span class="hs-identifier hs-var hs-var">substTys</span></a></span></span><span> </span><span id="local-6989586621680854922"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854922"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680854921"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854921"><span class="hs-identifier hs-var">tys</span></a></span></span><span>
</span><span id="line-687"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; Bool
</span><a href="GHC.Core.TyCo.Subst.html#isEmptyTCvSubst"><span class="hs-identifier hs-var">isEmptyTCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854922"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854921"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-688"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; [Type] -&gt; [Coercion] -&gt; [Type] -&gt; [Type]
forall a.
HasCallStack =&gt;
TCvSubst -&gt; [Type] -&gt; [Coercion] -&gt; a -&gt; a
</span><a href="GHC.Core.TyCo.Subst.html#checkValidSubst"><span class="hs-identifier hs-var">checkValidSubst</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854922"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854921"><span class="hs-identifier hs-var">tys</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">([Type] -&gt; [Type]) -&gt; [Type] -&gt; [Type]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(Type -&gt; Type) -&gt; [Type] -&gt; [Type]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#subst_ty"><span class="hs-identifier hs-var">subst_ty</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854922"><span class="hs-identifier hs-var">subst</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854921"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-689"></span><span>
</span><span id="line-690"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substScaledTys"><span class="hs-identifier hs-type">substScaledTys</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Stack.Types.html#HasCallStack"><span class="hs-identifier hs-type">HasCallStack</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-type">Scaled</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-type">Scaled</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-691"></span><span id="substScaledTys"><span class="annot"><span class="annottext">substScaledTys :: HasCallStack =&gt; TCvSubst -&gt; [Scaled Type] -&gt; [Scaled Type]
</span><a href="GHC.Core.TyCo.Subst.html#substScaledTys"><span class="hs-identifier hs-var hs-var">substScaledTys</span></a></span></span><span> </span><span id="local-6989586621680854917"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854917"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680854916"><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621680854916"><span class="hs-identifier hs-var">scaled_tys</span></a></span></span><span>
</span><span id="line-692"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; Bool
</span><a href="GHC.Core.TyCo.Subst.html#isEmptyTCvSubst"><span class="hs-identifier hs-var">isEmptyTCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854917"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621680854916"><span class="hs-identifier hs-var">scaled_tys</span></a></span><span>
</span><span id="line-693"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; [Type] -&gt; [Coercion] -&gt; [Scaled Type] -&gt; [Scaled Type]
forall a.
HasCallStack =&gt;
TCvSubst -&gt; [Type] -&gt; [Coercion] -&gt; a -&gt; a
</span><a href="GHC.Core.TyCo.Subst.html#checkValidSubst"><span class="hs-identifier hs-var">checkValidSubst</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854917"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Scaled Type -&gt; Type) -&gt; [Scaled Type] -&gt; [Type]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Scaled Type -&gt; Type
forall a. Scaled a -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#scaledMult"><span class="hs-identifier hs-var">scaledMult</span></a></span><span> </span><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621680854916"><span class="hs-identifier hs-var">scaled_tys</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; [Type] -&gt; [Type]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">(Scaled Type -&gt; Type) -&gt; [Scaled Type] -&gt; [Type]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Scaled Type -&gt; Type
forall a. Scaled a -&gt; a
</span><a href="GHC.Core.TyCo.Rep.html#scaledThing"><span class="hs-identifier hs-var">scaledThing</span></a></span><span> </span><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621680854916"><span class="hs-identifier hs-var">scaled_tys</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">([Scaled Type] -&gt; [Scaled Type]) -&gt; [Scaled Type] -&gt; [Scaled Type]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-694"></span><span>                </span><span class="annot"><span class="annottext">(Scaled Type -&gt; Scaled Type) -&gt; [Scaled Type] -&gt; [Scaled Type]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Type -&gt; Type) -&gt; Scaled Type -&gt; Scaled Type
</span><a href="GHC.Core.TyCo.Rep.html#mapScaledType"><span class="hs-identifier hs-var">mapScaledType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#subst_ty"><span class="hs-identifier hs-var">subst_ty</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854917"><span class="hs-identifier hs-var">subst</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621680854916"><span class="hs-identifier hs-var">scaled_tys</span></a></span><span>
</span><span id="line-695"></span><span>
</span><span id="line-696"></span><span class="hs-comment">-- | Substitute within several 'Type's disabling the sanity checks.</span><span>
</span><span id="line-697"></span><span class="hs-comment">-- The problems that the sanity checks in substTys catch are described in</span><span>
</span><span id="line-698"></span><span class="hs-comment">-- Note [The substitution invariant].</span><span>
</span><span id="line-699"></span><span class="hs-comment">-- The goal of #11371 is to migrate all the calls of substTysUnchecked to</span><span>
</span><span id="line-700"></span><span class="hs-comment">-- substTys and remove this function. Please don't use in new code.</span><span>
</span><span id="line-701"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTysUnchecked"><span class="hs-identifier hs-type">substTysUnchecked</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-702"></span><span id="substTysUnchecked"><span class="annot"><span class="annottext">substTysUnchecked :: TCvSubst -&gt; [Type] -&gt; [Type]
</span><a href="GHC.Core.TyCo.Subst.html#substTysUnchecked"><span class="hs-identifier hs-var hs-var">substTysUnchecked</span></a></span></span><span> </span><span id="local-6989586621680854913"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854913"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680854912"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854912"><span class="hs-identifier hs-var">tys</span></a></span></span><span>
</span><span id="line-703"></span><span>                 </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; Bool
</span><a href="GHC.Core.TyCo.Subst.html#isEmptyTCvSubst"><span class="hs-identifier hs-var">isEmptyTCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854913"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854912"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-704"></span><span>                 </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Type -&gt; Type) -&gt; [Type] -&gt; [Type]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#subst_ty"><span class="hs-identifier hs-var">subst_ty</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854913"><span class="hs-identifier hs-var">subst</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854912"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-705"></span><span>
</span><span id="line-706"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substScaledTysUnchecked"><span class="hs-identifier hs-type">substScaledTysUnchecked</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-type">Scaled</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-type">Scaled</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-707"></span><span id="substScaledTysUnchecked"><span class="annot"><span class="annottext">substScaledTysUnchecked :: TCvSubst -&gt; [Scaled Type] -&gt; [Scaled Type]
</span><a href="GHC.Core.TyCo.Subst.html#substScaledTysUnchecked"><span class="hs-identifier hs-var hs-var">substScaledTysUnchecked</span></a></span></span><span> </span><span id="local-6989586621680854911"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854911"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680854910"><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621680854910"><span class="hs-identifier hs-var">tys</span></a></span></span><span>
</span><span id="line-708"></span><span>                 </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; Bool
</span><a href="GHC.Core.TyCo.Subst.html#isEmptyTCvSubst"><span class="hs-identifier hs-var">isEmptyTCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854911"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621680854910"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-709"></span><span>                 </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Scaled Type -&gt; Scaled Type) -&gt; [Scaled Type] -&gt; [Scaled Type]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Type -&gt; Type) -&gt; Scaled Type -&gt; Scaled Type
</span><a href="GHC.Core.TyCo.Rep.html#mapScaledType"><span class="hs-identifier hs-var">mapScaledType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#subst_ty"><span class="hs-identifier hs-var">subst_ty</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854911"><span class="hs-identifier hs-var">subst</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621680854910"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-710"></span><span>
</span><span id="line-711"></span><span class="hs-comment">-- | Substitute within a 'ThetaType'</span><span>
</span><span id="line-712"></span><span class="hs-comment">-- The substitution has to satisfy the invariants described in</span><span>
</span><span id="line-713"></span><span class="hs-comment">-- Note [The substitution invariant].</span><span>
</span><span id="line-714"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTheta"><span class="hs-identifier hs-type">substTheta</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Stack.Types.html#HasCallStack"><span class="hs-identifier hs-type">HasCallStack</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ThetaType"><span class="hs-identifier hs-type">ThetaType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ThetaType"><span class="hs-identifier hs-type">ThetaType</span></a></span><span>
</span><span id="line-715"></span><span id="substTheta"><span class="annot"><span class="annottext">substTheta :: HasCallStack =&gt; TCvSubst -&gt; [Type] -&gt; [Type]
</span><a href="GHC.Core.TyCo.Subst.html#substTheta"><span class="hs-identifier hs-var hs-var">substTheta</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; [Type] -&gt; [Type]
TCvSubst -&gt; [Type] -&gt; [Type]
</span><a href="GHC.Core.TyCo.Subst.html#substTys"><span class="hs-identifier hs-var">substTys</span></a></span><span>
</span><span id="line-716"></span><span>
</span><span id="line-717"></span><span class="hs-comment">-- | Substitute within a 'ThetaType' disabling the sanity checks.</span><span>
</span><span id="line-718"></span><span class="hs-comment">-- The problems that the sanity checks in substTys catch are described in</span><span>
</span><span id="line-719"></span><span class="hs-comment">-- Note [The substitution invariant].</span><span>
</span><span id="line-720"></span><span class="hs-comment">-- The goal of #11371 is to migrate all the calls of substThetaUnchecked to</span><span>
</span><span id="line-721"></span><span class="hs-comment">-- substTheta and remove this function. Please don't use in new code.</span><span>
</span><span id="line-722"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substThetaUnchecked"><span class="hs-identifier hs-type">substThetaUnchecked</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ThetaType"><span class="hs-identifier hs-type">ThetaType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ThetaType"><span class="hs-identifier hs-type">ThetaType</span></a></span><span>
</span><span id="line-723"></span><span id="substThetaUnchecked"><span class="annot"><span class="annottext">substThetaUnchecked :: TCvSubst -&gt; [Type] -&gt; [Type]
</span><a href="GHC.Core.TyCo.Subst.html#substThetaUnchecked"><span class="hs-identifier hs-var hs-var">substThetaUnchecked</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; [Type] -&gt; [Type]
</span><a href="GHC.Core.TyCo.Subst.html#substTysUnchecked"><span class="hs-identifier hs-var">substTysUnchecked</span></a></span><span>
</span><span id="line-724"></span><span>
</span><span id="line-725"></span><span>
</span><span id="line-726"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#subst_ty"><span class="hs-identifier hs-type">subst_ty</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-727"></span><span class="hs-comment">-- subst_ty is the main workhorse for type substitution</span><span>
</span><span id="line-728"></span><span class="hs-comment">--</span><span>
</span><span id="line-729"></span><span class="hs-comment">-- Note that the in_scope set is poked only if we hit a forall</span><span>
</span><span id="line-730"></span><span class="hs-comment">-- so it may often never be fully computed</span><span>
</span><span id="line-731"></span><span id="subst_ty"><span class="annot"><span class="annottext">subst_ty :: TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#subst_ty"><span class="hs-identifier hs-var hs-var">subst_ty</span></a></span></span><span> </span><span id="local-6989586621680854905"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854905"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680854904"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854904"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-732"></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Type
</span><a href="#local-6989586621680854903"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854904"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-733"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-734"></span><span>    </span><span id="local-6989586621680854903"><span class="annot"><span class="annottext">go :: Type -&gt; Type
</span><a href="#local-6989586621680854903"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyVarTy"><span class="hs-identifier hs-type">TyVarTy</span></a></span><span> </span><span id="local-6989586621680854901"><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854901"><span class="hs-identifier hs-var">tv</span></a></span></span><span class="hs-special">)</span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; TyCoVar -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTyVar"><span class="hs-identifier hs-var">substTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854905"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854901"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-735"></span><span>    </span><span class="annot"><a href="#local-6989586621680854903"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#AppTy"><span class="hs-identifier hs-type">AppTy</span></a></span><span> </span><span id="local-6989586621680854899"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854899"><span class="hs-identifier hs-var">fun</span></a></span></span><span> </span><span id="local-6989586621680854898"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854898"><span class="hs-identifier hs-var">arg</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Type -&gt; Type
</span><a href="GHC.Core.Type.html#mkAppTy"><span class="hs-identifier hs-var">mkAppTy</span></a></span><span> </span><span class="annot"><span class="annottext">(Type -&gt; Type -&gt; Type) -&gt; Type -&gt; Type -&gt; Type
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Type
</span><a href="#local-6989586621680854903"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854899"><span class="hs-identifier hs-var">fun</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(Type -&gt; Type) -&gt; Type -&gt; Type
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Type
</span><a href="#local-6989586621680854903"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854898"><span class="hs-identifier hs-var">arg</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-736"></span><span>                </span><span class="hs-comment">-- The mkAppTy smart constructor is important</span><span>
</span><span id="line-737"></span><span>                </span><span class="hs-comment">-- we might be replacing (a Int), represented with App</span><span>
</span><span id="line-738"></span><span>                </span><span class="hs-comment">-- by [Int], represented with TyConApp</span><span>
</span><span id="line-739"></span><span>    </span><span class="annot"><a href="#local-6989586621680854903"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621680854896"><span class="annot"><span class="annottext">ty :: Type
</span><a href="#local-6989586621680854896"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyConApp"><span class="hs-identifier hs-type">TyConApp</span></a></span><span> </span><span id="local-6989586621680854894"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621680854894"><span class="hs-identifier hs-var">tc</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621680854894"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Type -&gt; Type
</span><span class="hs-operator hs-var">`seq`</span></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854896"><span class="hs-identifier hs-var">ty</span></a></span><span>  </span><span class="hs-comment">-- avoid allocation in this common case</span><span>
</span><span id="line-740"></span><span>    </span><span class="annot"><a href="#local-6989586621680854903"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyConApp"><span class="hs-identifier hs-type">TyConApp</span></a></span><span> </span><span id="local-6989586621680854893"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621680854893"><span class="hs-identifier hs-var">tc</span></a></span></span><span> </span><span id="local-6989586621680854892"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854892"><span class="hs-identifier hs-var">tys</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; [Type] -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#mkTyConApp"><span class="hs-identifier hs-var">mkTyConApp</span></a></span><span> </span><span class="annot"><span class="annottext">(TyCon -&gt; [Type] -&gt; Type) -&gt; TyCon -&gt; [Type] -&gt; Type
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621680854893"><span class="hs-identifier hs-var">tc</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">([Type] -&gt; Type) -&gt; [Type] -&gt; Type
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="annot"><span class="annottext">(Type -&gt; Type) -&gt; [Type] -&gt; [Type]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="GHC.Utils.Misc.html#strictMap"><span class="hs-identifier hs-var">strictMap</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Type
</span><a href="#local-6989586621680854903"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854892"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-741"></span><span>                               </span><span class="hs-comment">-- NB: mkTyConApp, not TyConApp.</span><span>
</span><span id="line-742"></span><span>                               </span><span class="hs-comment">-- mkTyConApp has optimizations.</span><span>
</span><span id="line-743"></span><span>                               </span><span class="hs-comment">-- See Note [mkTyConApp and Type] in GHC.Core.TyCo.Rep</span><span>
</span><span id="line-744"></span><span>    </span><span class="annot"><a href="#local-6989586621680854903"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621680854889"><span class="annot"><span class="annottext">ty :: Type
</span><a href="#local-6989586621680854889"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#FunTy"><span class="hs-identifier hs-type">FunTy</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ft_mult :: Type -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#ft_mult"><span class="hs-identifier hs-var">ft_mult</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680854886"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854886"><span class="hs-identifier hs-var">mult</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ft_arg :: Type -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#ft_arg"><span class="hs-identifier hs-var">ft_arg</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680854884"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854884"><span class="hs-identifier hs-var">arg</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ft_res :: Type -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#ft_res"><span class="hs-identifier hs-var">ft_res</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680854882"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854882"><span class="hs-identifier hs-var">res</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-745"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621680854881"><span class="annot"><span class="annottext">mult' :: Type
</span><a href="#local-6989586621680854881"><span class="hs-identifier hs-var hs-var">mult'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Type
</span><a href="#local-6989586621680854903"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854886"><span class="hs-identifier hs-var">mult</span></a></span><span>
</span><span id="line-746"></span><span>            </span><span class="hs-glyph">!</span><span id="local-6989586621680854880"><span class="annot"><span class="annottext">arg' :: Type
</span><a href="#local-6989586621680854880"><span class="hs-identifier hs-var hs-var">arg'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Type
</span><a href="#local-6989586621680854903"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854884"><span class="hs-identifier hs-var">arg</span></a></span><span>
</span><span id="line-747"></span><span>            </span><span class="hs-glyph">!</span><span id="local-6989586621680854879"><span class="annot"><span class="annottext">res' :: Type
</span><a href="#local-6989586621680854879"><span class="hs-identifier hs-var hs-var">res'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Type
</span><a href="#local-6989586621680854903"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854882"><span class="hs-identifier hs-var">res</span></a></span><span>
</span><span id="line-748"></span><span>        </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854889"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ft_mult :: Type
</span><a href="GHC.Core.TyCo.Rep.html#ft_mult"><span class="hs-identifier hs-var">ft_mult</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854881"><span class="hs-identifier hs-var">mult'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ft_arg :: Type
</span><a href="GHC.Core.TyCo.Rep.html#ft_arg"><span class="hs-identifier hs-var">ft_arg</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854880"><span class="hs-identifier hs-var">arg'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ft_res :: Type
</span><a href="GHC.Core.TyCo.Rep.html#ft_res"><span class="hs-identifier hs-var">ft_res</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854879"><span class="hs-identifier hs-var">res'</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-749"></span><span>    </span><span class="annot"><a href="#local-6989586621680854903"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ForAllTy"><span class="hs-identifier hs-type">ForAllTy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Bndr"><span class="hs-identifier hs-type">Bndr</span></a></span><span> </span><span id="local-6989586621680854877"><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854877"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span id="local-6989586621680854876"><span class="annot"><span class="annottext">ArgFlag
</span><a href="#local-6989586621680854876"><span class="hs-identifier hs-var">vis</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680854875"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854875"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-750"></span><span>                         </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; TyCoVar -&gt; (TCvSubst, TyCoVar)
</span><a href="GHC.Core.TyCo.Subst.html#substVarBndrUnchecked"><span class="hs-identifier hs-var">substVarBndrUnchecked</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854905"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854877"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-751"></span><span>                             </span><span class="hs-special">(</span><span id="local-6989586621680854873"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854873"><span class="hs-identifier hs-var">subst'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680854872"><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854872"><span class="hs-identifier hs-var">tv'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-752"></span><span>                               </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarBndr TyCoVar ArgFlag -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#ForAllTy"><span class="hs-identifier hs-var">ForAllTy</span></a></span><span> </span><span class="annot"><span class="annottext">(VarBndr TyCoVar ArgFlag -&gt; Type -&gt; Type)
-&gt; VarBndr TyCoVar ArgFlag -&gt; Type -&gt; Type
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCoVar -&gt; ArgFlag -&gt; VarBndr TyCoVar ArgFlag
forall var argf. var -&gt; argf -&gt; VarBndr var argf
</span><a href="GHC.Types.Var.html#Bndr"><span class="hs-identifier hs-var">Bndr</span></a></span><span> </span><span class="annot"><span class="annottext">(TyCoVar -&gt; ArgFlag -&gt; VarBndr TyCoVar ArgFlag)
-&gt; TyCoVar -&gt; ArgFlag -&gt; VarBndr TyCoVar ArgFlag
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854872"><span class="hs-identifier hs-var">tv'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">ArgFlag
</span><a href="#local-6989586621680854876"><span class="hs-identifier hs-var">vis</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(Type -&gt; Type) -&gt; Type -&gt; Type
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span>
</span><span id="line-753"></span><span>                                            </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#subst_ty"><span class="hs-identifier hs-var">subst_ty</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854873"><span class="hs-identifier hs-var">subst'</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854875"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-754"></span><span>    </span><span class="annot"><a href="#local-6989586621680854903"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#LitTy"><span class="hs-identifier hs-type">LitTy</span></a></span><span> </span><span id="local-6989586621680854870"><span class="annot"><span class="annottext">TyLit
</span><a href="#local-6989586621680854870"><span class="hs-identifier hs-var">n</span></a></span></span><span class="hs-special">)</span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyLit -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#LitTy"><span class="hs-identifier hs-var">LitTy</span></a></span><span> </span><span class="annot"><span class="annottext">(TyLit -&gt; Type) -&gt; TyLit -&gt; Type
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="annot"><span class="annottext">TyLit
</span><a href="#local-6989586621680854870"><span class="hs-identifier hs-var">n</span></a></span><span>
</span><span id="line-755"></span><span>    </span><span class="annot"><a href="#local-6989586621680854903"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CastTy"><span class="hs-identifier hs-type">CastTy</span></a></span><span> </span><span id="local-6989586621680854868"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854868"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621680854867"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854867"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Coercion -&gt; Type
</span><a href="GHC.Core.Type.html#mkCastTy"><span class="hs-identifier hs-var">mkCastTy</span></a></span><span> </span><span class="annot"><span class="annottext">(Type -&gt; Coercion -&gt; Type) -&gt; Type -&gt; Coercion -&gt; Type
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Type
</span><a href="#local-6989586621680854903"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854868"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; Type) -&gt; Coercion -&gt; Type
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.TyCo.Subst.html#subst_co"><span class="hs-identifier hs-var">subst_co</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854905"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854867"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-756"></span><span>    </span><span class="annot"><a href="#local-6989586621680854903"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CoercionTy"><span class="hs-identifier hs-type">CoercionTy</span></a></span><span> </span><span id="local-6989586621680854865"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854865"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#CoercionTy"><span class="hs-identifier hs-var">CoercionTy</span></a></span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; Type) -&gt; Coercion -&gt; Type
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.TyCo.Subst.html#subst_co"><span class="hs-identifier hs-var">subst_co</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854905"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854865"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-757"></span><span>
</span><span id="line-758"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTyVar"><span class="hs-identifier hs-type">substTyVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-759"></span><span id="substTyVar"><span class="annot"><span class="annottext">substTyVar :: TCvSubst -&gt; TyCoVar -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTyVar"><span class="hs-identifier hs-var hs-var">substTyVar</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680854864"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854864"><span class="hs-identifier hs-var">tenv</span></a></span></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680854863"><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854863"><span class="hs-identifier hs-var">tv</span></a></span></span><span>
</span><span id="line-760"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isTyVar</span><span> </span><span class="hs-identifier">tv</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-761"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv -&gt; TyCoVar -&gt; Maybe Type
forall a. VarEnv a -&gt; TyCoVar -&gt; Maybe a
</span><a href="GHC.Types.Var.Env.html#lookupVarEnv"><span class="hs-identifier hs-var">lookupVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854864"><span class="hs-identifier hs-var">tenv</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854863"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-762"></span><span>      </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680854861"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854861"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854861"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-763"></span><span>      </span><span class="annot"><span class="annottext">Maybe Type
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TyCoVar -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#TyVarTy"><span class="hs-identifier hs-var">TyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854863"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-764"></span><span>
</span><span id="line-765"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTyVars"><span class="hs-identifier hs-type">substTyVars</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-766"></span><span id="substTyVars"><span class="annot"><span class="annottext">substTyVars :: TCvSubst -&gt; [TyCoVar] -&gt; [Type]
</span><a href="GHC.Core.TyCo.Subst.html#substTyVars"><span class="hs-identifier hs-var hs-var">substTyVars</span></a></span></span><span> </span><span id="local-6989586621680854860"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854860"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TyCoVar -&gt; Type) -&gt; [TyCoVar] -&gt; [Type]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">((TyCoVar -&gt; Type) -&gt; [TyCoVar] -&gt; [Type])
-&gt; (TyCoVar -&gt; Type) -&gt; [TyCoVar] -&gt; [Type]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; TyCoVar -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTyVar"><span class="hs-identifier hs-var">substTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854860"><span class="hs-identifier hs-var">subst</span></a></span><span>
</span><span id="line-767"></span><span>
</span><span id="line-768"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTyCoVars"><span class="hs-identifier hs-type">substTyCoVars</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-769"></span><span id="substTyCoVars"><span class="annot"><span class="annottext">substTyCoVars :: TCvSubst -&gt; [TyCoVar] -&gt; [Type]
</span><a href="GHC.Core.TyCo.Subst.html#substTyCoVars"><span class="hs-identifier hs-var hs-var">substTyCoVars</span></a></span></span><span> </span><span id="local-6989586621680854859"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854859"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TyCoVar -&gt; Type) -&gt; [TyCoVar] -&gt; [Type]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">((TyCoVar -&gt; Type) -&gt; [TyCoVar] -&gt; [Type])
-&gt; (TyCoVar -&gt; Type) -&gt; [TyCoVar] -&gt; [Type]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; TyCoVar -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTyCoVar"><span class="hs-identifier hs-var">substTyCoVar</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854859"><span class="hs-identifier hs-var">subst</span></a></span><span>
</span><span id="line-770"></span><span>
</span><span id="line-771"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTyCoVar"><span class="hs-identifier hs-type">substTyCoVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-772"></span><span id="substTyCoVar"><span class="annot"><span class="annottext">substTyCoVar :: TCvSubst -&gt; TyCoVar -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTyCoVar"><span class="hs-identifier hs-var hs-var">substTyCoVar</span></a></span></span><span> </span><span id="local-6989586621680854857"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854857"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680854856"><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854856"><span class="hs-identifier hs-var">tv</span></a></span></span><span>
</span><span id="line-773"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCoVar -&gt; Bool
</span><a href="GHC.Types.Var.html#isTyVar"><span class="hs-identifier hs-var">isTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854856"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; TyCoVar -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTyVar"><span class="hs-identifier hs-var">substTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854857"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854856"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-774"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#CoercionTy"><span class="hs-identifier hs-var">CoercionTy</span></a></span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; Type) -&gt; Coercion -&gt; Type
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; TyCoVar -&gt; Coercion
</span><a href="GHC.Core.TyCo.Subst.html#substCoVar"><span class="hs-identifier hs-var">substCoVar</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854857"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854856"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-775"></span><span>
</span><span id="line-776"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#lookupTyVar"><span class="hs-identifier hs-type">lookupTyVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-777"></span><span>        </span><span class="hs-comment">-- See Note [Extending the TCvSubst]</span><span>
</span><span id="line-778"></span><span id="lookupTyVar"><span class="annot"><span class="annottext">lookupTyVar :: TCvSubst -&gt; TyCoVar -&gt; Maybe Type
</span><a href="GHC.Core.TyCo.Subst.html#lookupTyVar"><span class="hs-identifier hs-var hs-var">lookupTyVar</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680854855"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854855"><span class="hs-identifier hs-var">tenv</span></a></span></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680854854"><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854854"><span class="hs-identifier hs-var">tv</span></a></span></span><span>
</span><span id="line-779"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isTyVar</span><span> </span><span class="hs-identifier">tv</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-780"></span><span>    </span><span class="annot"><span class="annottext">TvSubstEnv -&gt; TyCoVar -&gt; Maybe Type
forall a. VarEnv a -&gt; TyCoVar -&gt; Maybe a
</span><a href="GHC.Types.Var.Env.html#lookupVarEnv"><span class="hs-identifier hs-var">lookupVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854855"><span class="hs-identifier hs-var">tenv</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854854"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-781"></span><span>
</span><span id="line-782"></span><span class="hs-comment">-- | Substitute within a 'Coercion'</span><span>
</span><span id="line-783"></span><span class="hs-comment">-- The substitution has to satisfy the invariants described in</span><span>
</span><span id="line-784"></span><span class="hs-comment">-- Note [The substitution invariant].</span><span>
</span><span id="line-785"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substCo"><span class="hs-identifier hs-type">substCo</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Stack.Types.html#HasCallStack"><span class="hs-identifier hs-type">HasCallStack</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span>
</span><span id="line-786"></span><span id="substCo"><span class="annot"><span class="annottext">substCo :: HasCallStack =&gt; TCvSubst -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.TyCo.Subst.html#substCo"><span class="hs-identifier hs-var hs-var">substCo</span></a></span></span><span> </span><span id="local-6989586621680854850"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854850"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680854849"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854849"><span class="hs-identifier hs-var">co</span></a></span></span><span>
</span><span id="line-787"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; Bool
</span><a href="GHC.Core.TyCo.Subst.html#isEmptyTCvSubst"><span class="hs-identifier hs-var">isEmptyTCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854850"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854849"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-788"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; [Type] -&gt; [Coercion] -&gt; Coercion -&gt; Coercion
forall a.
HasCallStack =&gt;
TCvSubst -&gt; [Type] -&gt; [Coercion] -&gt; a -&gt; a
</span><a href="GHC.Core.TyCo.Subst.html#checkValidSubst"><span class="hs-identifier hs-var">checkValidSubst</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854850"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854849"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; Coercion) -&gt; Coercion -&gt; Coercion
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.TyCo.Subst.html#subst_co"><span class="hs-identifier hs-var">subst_co</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854850"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854849"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-789"></span><span>
</span><span id="line-790"></span><span class="hs-comment">-- | Substitute within a 'Coercion' disabling sanity checks.</span><span>
</span><span id="line-791"></span><span class="hs-comment">-- The problems that the sanity checks in substCo catch are described in</span><span>
</span><span id="line-792"></span><span class="hs-comment">-- Note [The substitution invariant].</span><span>
</span><span id="line-793"></span><span class="hs-comment">-- The goal of #11371 is to migrate all the calls of substCoUnchecked to</span><span>
</span><span id="line-794"></span><span class="hs-comment">-- substCo and remove this function. Please don't use in new code.</span><span>
</span><span id="line-795"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substCoUnchecked"><span class="hs-identifier hs-type">substCoUnchecked</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span>
</span><span id="line-796"></span><span id="substCoUnchecked"><span class="annot"><span class="annottext">substCoUnchecked :: TCvSubst -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.TyCo.Subst.html#substCoUnchecked"><span class="hs-identifier hs-var hs-var">substCoUnchecked</span></a></span></span><span> </span><span id="local-6989586621680854848"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854848"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680854847"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854847"><span class="hs-identifier hs-var">co</span></a></span></span><span>
</span><span id="line-797"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; Bool
</span><a href="GHC.Core.TyCo.Subst.html#isEmptyTCvSubst"><span class="hs-identifier hs-var">isEmptyTCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854848"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854847"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-798"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.TyCo.Subst.html#subst_co"><span class="hs-identifier hs-var">subst_co</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854848"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854847"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-799"></span><span>
</span><span id="line-800"></span><span class="hs-comment">-- | Substitute within several 'Coercion's</span><span>
</span><span id="line-801"></span><span class="hs-comment">-- The substitution has to satisfy the invariants described in</span><span>
</span><span id="line-802"></span><span class="hs-comment">-- Note [The substitution invariant].</span><span>
</span><span id="line-803"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substCos"><span class="hs-identifier hs-type">substCos</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Stack.Types.html#HasCallStack"><span class="hs-identifier hs-type">HasCallStack</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-804"></span><span id="substCos"><span class="annot"><span class="annottext">substCos :: HasCallStack =&gt; TCvSubst -&gt; [Coercion] -&gt; [Coercion]
</span><a href="GHC.Core.TyCo.Subst.html#substCos"><span class="hs-identifier hs-var hs-var">substCos</span></a></span></span><span> </span><span id="local-6989586621680854843"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854843"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680854842"><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680854842"><span class="hs-identifier hs-var">cos</span></a></span></span><span>
</span><span id="line-805"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; Bool
</span><a href="GHC.Core.TyCo.Subst.html#isEmptyTCvSubst"><span class="hs-identifier hs-var">isEmptyTCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854843"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680854842"><span class="hs-identifier hs-var">cos</span></a></span><span>
</span><span id="line-806"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; [Type] -&gt; [Coercion] -&gt; [Coercion] -&gt; [Coercion]
forall a.
HasCallStack =&gt;
TCvSubst -&gt; [Type] -&gt; [Coercion] -&gt; a -&gt; a
</span><a href="GHC.Core.TyCo.Subst.html#checkValidSubst"><span class="hs-identifier hs-var">checkValidSubst</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854843"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680854842"><span class="hs-identifier hs-var">cos</span></a></span><span> </span><span class="annot"><span class="annottext">([Coercion] -&gt; [Coercion]) -&gt; [Coercion] -&gt; [Coercion]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; Coercion) -&gt; [Coercion] -&gt; [Coercion]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.TyCo.Subst.html#subst_co"><span class="hs-identifier hs-var">subst_co</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854843"><span class="hs-identifier hs-var">subst</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680854842"><span class="hs-identifier hs-var">cos</span></a></span><span>
</span><span id="line-807"></span><span>
</span><span id="line-808"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#subst_co"><span class="hs-identifier hs-type">subst_co</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span>
</span><span id="line-809"></span><span id="subst_co"><span class="annot"><span class="annottext">subst_co :: TCvSubst -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.TyCo.Subst.html#subst_co"><span class="hs-identifier hs-var hs-var">subst_co</span></a></span></span><span> </span><span id="local-6989586621680854841"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854841"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680854840"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854840"><span class="hs-identifier hs-var">co</span></a></span></span><span>
</span><span id="line-810"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="#local-6989586621680854839"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854840"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-811"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-812"></span><span>    </span><span class="annot"><a href="#local-6989586621680854838"><span class="hs-identifier hs-type">go_ty</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-813"></span><span>    </span><span id="local-6989586621680854838"><span class="annot"><span class="annottext">go_ty :: Type -&gt; Type
</span><a href="#local-6989586621680854838"><span class="hs-identifier hs-var hs-var">go_ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#subst_ty"><span class="hs-identifier hs-var">subst_ty</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854841"><span class="hs-identifier hs-var">subst</span></a></span><span>
</span><span id="line-814"></span><span>
</span><span id="line-815"></span><span>    </span><span class="annot"><a href="#local-6989586621680854837"><span class="hs-identifier hs-type">go_mco</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#MCoercion"><span class="hs-identifier hs-type">MCoercion</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#MCoercion"><span class="hs-identifier hs-type">MCoercion</span></a></span><span>
</span><span id="line-816"></span><span>    </span><span id="local-6989586621680854837"><span class="annot"><span class="annottext">go_mco :: MCoercion -&gt; MCoercion
</span><a href="#local-6989586621680854837"><span class="hs-identifier hs-var hs-var">go_mco</span></a></span></span><span> </span><span class="annot"><span class="annottext">MCoercion
</span><a href="GHC.Core.TyCo.Rep.html#MRefl"><span class="hs-identifier hs-var">MRefl</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MCoercion
</span><a href="GHC.Core.TyCo.Rep.html#MRefl"><span class="hs-identifier hs-var">MRefl</span></a></span><span>
</span><span id="line-817"></span><span>    </span><span class="annot"><a href="#local-6989586621680854837"><span class="hs-identifier hs-var">go_mco</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#MCo"><span class="hs-identifier hs-type">MCo</span></a></span><span> </span><span id="local-6989586621680854834"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854834"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; MCoercion
</span><a href="GHC.Core.TyCo.Rep.html#MCo"><span class="hs-identifier hs-var">MCo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="#local-6989586621680854839"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854834"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-818"></span><span>
</span><span id="line-819"></span><span>    </span><span class="annot"><a href="#local-6989586621680854839"><span class="hs-identifier hs-type">go</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span>
</span><span id="line-820"></span><span>    </span><span id="local-6989586621680854839"><span class="annot"><span class="annottext">go :: Coercion -&gt; Coercion
</span><a href="#local-6989586621680854839"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Refl"><span class="hs-identifier hs-type">Refl</span></a></span><span> </span><span id="local-6989586621680854832"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854832"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkNomReflCo"><span class="hs-identifier hs-var">mkNomReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">(Type -&gt; Coercion) -&gt; Type -&gt; Coercion
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Type
</span><a href="#local-6989586621680854838"><span class="hs-identifier hs-var">go_ty</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854832"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-821"></span><span>    </span><span class="annot"><a href="#local-6989586621680854839"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#GRefl"><span class="hs-identifier hs-type">GRefl</span></a></span><span> </span><span id="local-6989586621680854830"><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621680854830"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span id="local-6989586621680854829"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854829"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621680854828"><span class="annot"><span class="annottext">MCoercion
</span><a href="#local-6989586621680854828"><span class="hs-identifier hs-var">mco</span></a></span></span><span class="hs-special">)</span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Role -&gt; Type -&gt; MCoercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkGReflCo"><span class="hs-identifier hs-var">mkGReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621680854830"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">(Type -&gt; MCoercion -&gt; Coercion) -&gt; Type -&gt; MCoercion -&gt; Coercion
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Type
</span><a href="#local-6989586621680854838"><span class="hs-identifier hs-var">go_ty</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854829"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(MCoercion -&gt; Coercion) -&gt; MCoercion -&gt; Coercion
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">MCoercion -&gt; MCoercion
</span><a href="#local-6989586621680854837"><span class="hs-identifier hs-var">go_mco</span></a></span><span> </span><span class="annot"><span class="annottext">MCoercion
</span><a href="#local-6989586621680854828"><span class="hs-identifier hs-var">mco</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-822"></span><span>    </span><span class="annot"><a href="#local-6989586621680854839"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyConAppCo"><span class="hs-identifier hs-type">TyConAppCo</span></a></span><span> </span><span id="local-6989586621680854826"><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621680854826"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span id="local-6989586621680854825"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621680854825"><span class="hs-identifier hs-var">tc</span></a></span></span><span> </span><span id="local-6989586621680854824"><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680854824"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">)</span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680854823"><span class="annot"><span class="annottext">args' :: [Coercion]
</span><a href="#local-6989586621680854823"><span class="hs-identifier hs-var hs-var">args'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; Coercion) -&gt; [Coercion] -&gt; [Coercion]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="#local-6989586621680854839"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680854824"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-823"></span><span>                               </span><span class="hs-keyword">in</span><span>  </span><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680854823"><span class="hs-identifier hs-var">args'</span></a></span><span> </span><span class="annot"><span class="annottext">[Coercion] -&gt; Coercion -&gt; Coercion
forall a b. [a] -&gt; b -&gt; b
</span><a href="GHC.Utils.Misc.html#seqList"><span class="hs-operator hs-var">`seqList`</span></a></span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Role -&gt; TyCon -&gt; [Coercion] -&gt; Coercion
Role -&gt; TyCon -&gt; [Coercion] -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkTyConAppCo"><span class="hs-identifier hs-var">mkTyConAppCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621680854826"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621680854825"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680854823"><span class="hs-identifier hs-var">args'</span></a></span><span>
</span><span id="line-824"></span><span>    </span><span class="annot"><a href="#local-6989586621680854839"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#AppCo"><span class="hs-identifier hs-type">AppCo</span></a></span><span> </span><span id="local-6989586621680854820"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854820"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span id="local-6989586621680854819"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854819"><span class="hs-identifier hs-var">arg</span></a></span></span><span class="hs-special">)</span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkAppCo"><span class="hs-identifier hs-var">mkAppCo</span></a></span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; Coercion -&gt; Coercion)
-&gt; Coercion -&gt; Coercion -&gt; Coercion
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="#local-6989586621680854839"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854820"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; Coercion) -&gt; Coercion -&gt; Coercion
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="#local-6989586621680854839"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854819"><span class="hs-identifier hs-var">arg</span></a></span><span>
</span><span id="line-825"></span><span>    </span><span class="annot"><a href="#local-6989586621680854839"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ForAllCo"><span class="hs-identifier hs-type">ForAllCo</span></a></span><span> </span><span id="local-6989586621680854817"><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854817"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span id="local-6989586621680854816"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854816"><span class="hs-identifier hs-var">kind_co</span></a></span></span><span> </span><span id="local-6989586621680854815"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854815"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-826"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; TyCoVar -&gt; Coercion -&gt; (TCvSubst, TyCoVar, Coercion)
</span><a href="GHC.Core.TyCo.Subst.html#substForAllCoBndrUnchecked"><span class="hs-identifier hs-var">substForAllCoBndrUnchecked</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854841"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854817"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854816"><span class="hs-identifier hs-var">kind_co</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-827"></span><span>         </span><span class="hs-special">(</span><span id="local-6989586621680854813"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854813"><span class="hs-identifier hs-var">subst'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680854812"><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854812"><span class="hs-identifier hs-var">tv'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680854811"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854811"><span class="hs-identifier hs-var">kind_co'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-828"></span><span>          </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCoVar -&gt; Coercion -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkForAllCo"><span class="hs-identifier hs-var">mkForAllCo</span></a></span><span> </span><span class="annot"><span class="annottext">(TyCoVar -&gt; Coercion -&gt; Coercion -&gt; Coercion)
-&gt; TyCoVar -&gt; Coercion -&gt; Coercion -&gt; Coercion
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854812"><span class="hs-identifier hs-var">tv'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; Coercion -&gt; Coercion)
-&gt; Coercion -&gt; Coercion -&gt; Coercion
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854811"><span class="hs-identifier hs-var">kind_co'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; Coercion) -&gt; Coercion -&gt; Coercion
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.TyCo.Subst.html#subst_co"><span class="hs-identifier hs-var">subst_co</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854813"><span class="hs-identifier hs-var">subst'</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854815"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-829"></span><span>    </span><span class="annot"><a href="#local-6989586621680854839"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#FunCo"><span class="hs-identifier hs-type">FunCo</span></a></span><span> </span><span id="local-6989586621680854809"><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621680854809"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span id="local-6989586621680854808"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854808"><span class="hs-identifier hs-var">w</span></a></span></span><span> </span><span id="local-6989586621680854807"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854807"><span class="hs-identifier hs-var">co1</span></a></span></span><span> </span><span id="local-6989586621680854806"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854806"><span class="hs-identifier hs-var">co2</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Role -&gt; Coercion -&gt; Coercion -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkFunCo"><span class="hs-identifier hs-var">mkFunCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621680854809"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; Coercion -&gt; Coercion -&gt; Coercion)
-&gt; Coercion -&gt; Coercion -&gt; Coercion -&gt; Coercion
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="#local-6989586621680854839"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854808"><span class="hs-identifier hs-var">w</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; Coercion -&gt; Coercion)
-&gt; Coercion -&gt; Coercion -&gt; Coercion
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="#local-6989586621680854839"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854807"><span class="hs-identifier hs-var">co1</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; Coercion) -&gt; Coercion -&gt; Coercion
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="#local-6989586621680854839"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854806"><span class="hs-identifier hs-var">co2</span></a></span><span>
</span><span id="line-830"></span><span>    </span><span class="annot"><a href="#local-6989586621680854839"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CoVarCo"><span class="hs-identifier hs-type">CoVarCo</span></a></span><span> </span><span id="local-6989586621680854804"><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854804"><span class="hs-identifier hs-var">cv</span></a></span></span><span class="hs-special">)</span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; TyCoVar -&gt; Coercion
</span><a href="GHC.Core.TyCo.Subst.html#substCoVar"><span class="hs-identifier hs-var">substCoVar</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854841"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854804"><span class="hs-identifier hs-var">cv</span></a></span><span>
</span><span id="line-831"></span><span>    </span><span class="annot"><a href="#local-6989586621680854839"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#AxiomInstCo"><span class="hs-identifier hs-type">AxiomInstCo</span></a></span><span> </span><span id="local-6989586621680854802"><span class="annot"><span class="annottext">CoAxiom Branched
</span><a href="#local-6989586621680854802"><span class="hs-identifier hs-var">con</span></a></span></span><span> </span><span id="local-6989586621680854801"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680854801"><span class="hs-identifier hs-var">ind</span></a></span></span><span> </span><span id="local-6989586621680854800"><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680854800"><span class="hs-identifier hs-var">cos</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoAxiom Branched -&gt; Int -&gt; [Coercion] -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkAxiomInstCo"><span class="hs-identifier hs-var">mkAxiomInstCo</span></a></span><span> </span><span class="annot"><span class="annottext">CoAxiom Branched
</span><a href="#local-6989586621680854802"><span class="hs-identifier hs-var">con</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680854801"><span class="hs-identifier hs-var">ind</span></a></span><span> </span><span class="annot"><span class="annottext">([Coercion] -&gt; Coercion) -&gt; [Coercion] -&gt; Coercion
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; Coercion) -&gt; [Coercion] -&gt; [Coercion]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="#local-6989586621680854839"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680854800"><span class="hs-identifier hs-var">cos</span></a></span><span>
</span><span id="line-832"></span><span>    </span><span class="annot"><a href="#local-6989586621680854839"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#UnivCo"><span class="hs-identifier hs-type">UnivCo</span></a></span><span> </span><span id="local-6989586621680854798"><span class="annot"><span class="annottext">UnivCoProvenance
</span><a href="#local-6989586621680854798"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span id="local-6989586621680854797"><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621680854797"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span id="local-6989586621680854796"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854796"><span class="hs-identifier hs-var">t1</span></a></span></span><span> </span><span id="local-6989586621680854795"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854795"><span class="hs-identifier hs-var">t2</span></a></span></span><span class="hs-special">)</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">UnivCoProvenance -&gt; Role -&gt; Type -&gt; Type -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkUnivCo"><span class="hs-identifier hs-var">mkUnivCo</span></a></span><span> </span><span class="annot"><span class="annottext">(UnivCoProvenance -&gt; Role -&gt; Type -&gt; Type -&gt; Coercion)
-&gt; UnivCoProvenance -&gt; Role -&gt; Type -&gt; Type -&gt; Coercion
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="annot"><span class="annottext">UnivCoProvenance -&gt; UnivCoProvenance
</span><a href="#local-6989586621680854794"><span class="hs-identifier hs-var">go_prov</span></a></span><span> </span><span class="annot"><span class="annottext">UnivCoProvenance
</span><a href="#local-6989586621680854798"><span class="hs-identifier hs-var">p</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(Role -&gt; Type -&gt; Type -&gt; Coercion)
-&gt; Role -&gt; Type -&gt; Type -&gt; Coercion
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621680854797"><span class="hs-identifier hs-var">r</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(Type -&gt; Type -&gt; Coercion) -&gt; Type -&gt; Type -&gt; Coercion
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span>
</span><span id="line-833"></span><span>                                </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Type
</span><a href="#local-6989586621680854838"><span class="hs-identifier hs-var">go_ty</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854796"><span class="hs-identifier hs-var">t1</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(Type -&gt; Coercion) -&gt; Type -&gt; Coercion
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Type
</span><a href="#local-6989586621680854838"><span class="hs-identifier hs-var">go_ty</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854795"><span class="hs-identifier hs-var">t2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-834"></span><span>    </span><span class="annot"><a href="#local-6989586621680854839"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#SymCo"><span class="hs-identifier hs-type">SymCo</span></a></span><span> </span><span id="local-6989586621680854792"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854792"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkSymCo"><span class="hs-identifier hs-var">mkSymCo</span></a></span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; Coercion) -&gt; Coercion -&gt; Coercion
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="#local-6989586621680854839"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854792"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-835"></span><span>    </span><span class="annot"><a href="#local-6989586621680854839"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TransCo"><span class="hs-identifier hs-type">TransCo</span></a></span><span> </span><span id="local-6989586621680854790"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854790"><span class="hs-identifier hs-var">co1</span></a></span></span><span> </span><span id="local-6989586621680854789"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854789"><span class="hs-identifier hs-var">co2</span></a></span></span><span class="hs-special">)</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkTransCo"><span class="hs-identifier hs-var">mkTransCo</span></a></span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; Coercion -&gt; Coercion)
-&gt; Coercion -&gt; Coercion -&gt; Coercion
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="#local-6989586621680854839"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854790"><span class="hs-identifier hs-var">co1</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; Coercion) -&gt; Coercion -&gt; Coercion
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="#local-6989586621680854839"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854789"><span class="hs-identifier hs-var">co2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-836"></span><span>    </span><span class="annot"><a href="#local-6989586621680854839"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#NthCo"><span class="hs-identifier hs-type">NthCo</span></a></span><span> </span><span id="local-6989586621680854787"><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621680854787"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span id="local-6989586621680854786"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680854786"><span class="hs-identifier hs-var">d</span></a></span></span><span> </span><span id="local-6989586621680854785"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854785"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Role -&gt; Int -&gt; Coercion -&gt; Coercion
Role -&gt; Int -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkNthCo"><span class="hs-identifier hs-var">mkNthCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621680854787"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680854786"><span class="hs-identifier hs-var">d</span></a></span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; Coercion) -&gt; Coercion -&gt; Coercion
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="#local-6989586621680854839"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854785"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-837"></span><span>    </span><span class="annot"><a href="#local-6989586621680854839"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#LRCo"><span class="hs-identifier hs-type">LRCo</span></a></span><span> </span><span id="local-6989586621680854783"><span class="annot"><span class="annottext">LeftOrRight
</span><a href="#local-6989586621680854783"><span class="hs-identifier hs-var">lr</span></a></span></span><span> </span><span id="local-6989586621680854782"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854782"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LeftOrRight -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkLRCo"><span class="hs-identifier hs-var">mkLRCo</span></a></span><span> </span><span class="annot"><span class="annottext">LeftOrRight
</span><a href="#local-6989586621680854783"><span class="hs-identifier hs-var">lr</span></a></span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; Coercion) -&gt; Coercion -&gt; Coercion
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="#local-6989586621680854839"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854782"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-838"></span><span>    </span><span class="annot"><a href="#local-6989586621680854839"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#InstCo"><span class="hs-identifier hs-type">InstCo</span></a></span><span> </span><span id="local-6989586621680854780"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854780"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span id="local-6989586621680854779"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854779"><span class="hs-identifier hs-var">arg</span></a></span></span><span class="hs-special">)</span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkInstCo"><span class="hs-identifier hs-var">mkInstCo</span></a></span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; Coercion -&gt; Coercion)
-&gt; Coercion -&gt; Coercion -&gt; Coercion
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="#local-6989586621680854839"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854780"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; Coercion) -&gt; Coercion -&gt; Coercion
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="#local-6989586621680854839"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854779"><span class="hs-identifier hs-var">arg</span></a></span><span>
</span><span id="line-839"></span><span>    </span><span class="annot"><a href="#local-6989586621680854839"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#KindCo"><span class="hs-identifier hs-type">KindCo</span></a></span><span> </span><span id="local-6989586621680854777"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854777"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkKindCo"><span class="hs-identifier hs-var">mkKindCo</span></a></span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; Coercion) -&gt; Coercion -&gt; Coercion
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="#local-6989586621680854839"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854777"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-840"></span><span>    </span><span class="annot"><a href="#local-6989586621680854839"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#SubCo"><span class="hs-identifier hs-type">SubCo</span></a></span><span> </span><span id="local-6989586621680854775"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854775"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkSubCo"><span class="hs-identifier hs-var">mkSubCo</span></a></span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; Coercion) -&gt; Coercion -&gt; Coercion
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="#local-6989586621680854839"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854775"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-841"></span><span>    </span><span class="annot"><a href="#local-6989586621680854839"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#AxiomRuleCo"><span class="hs-identifier hs-type">AxiomRuleCo</span></a></span><span> </span><span id="local-6989586621680854773"><span class="annot"><span class="annottext">CoAxiomRule
</span><a href="#local-6989586621680854773"><span class="hs-identifier hs-var">c</span></a></span></span><span> </span><span id="local-6989586621680854772"><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680854772"><span class="hs-identifier hs-var">cs</span></a></span></span><span class="hs-special">)</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680854771"><span class="annot"><span class="annottext">cs1 :: [Coercion]
</span><a href="#local-6989586621680854771"><span class="hs-identifier hs-var hs-var">cs1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; Coercion) -&gt; [Coercion] -&gt; [Coercion]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="#local-6989586621680854839"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680854772"><span class="hs-identifier hs-var">cs</span></a></span><span>
</span><span id="line-842"></span><span>                                </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680854771"><span class="hs-identifier hs-var">cs1</span></a></span><span> </span><span class="annot"><span class="annottext">[Coercion] -&gt; Coercion -&gt; Coercion
forall a b. [a] -&gt; b -&gt; b
</span><a href="GHC.Utils.Misc.html#seqList"><span class="hs-operator hs-var">`seqList`</span></a></span><span> </span><span class="annot"><span class="annottext">CoAxiomRule -&gt; [Coercion] -&gt; Coercion
</span><a href="GHC.Core.TyCo.Rep.html#AxiomRuleCo"><span class="hs-identifier hs-var">AxiomRuleCo</span></a></span><span> </span><span class="annot"><span class="annottext">CoAxiomRule
</span><a href="#local-6989586621680854773"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680854771"><span class="hs-identifier hs-var">cs1</span></a></span><span>
</span><span id="line-843"></span><span>    </span><span class="annot"><a href="#local-6989586621680854839"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#HoleCo"><span class="hs-identifier hs-type">HoleCo</span></a></span><span> </span><span id="local-6989586621680854769"><span class="annot"><span class="annottext">CoercionHole
</span><a href="#local-6989586621680854769"><span class="hs-identifier hs-var">h</span></a></span></span><span class="hs-special">)</span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoercionHole -&gt; Coercion
</span><a href="GHC.Core.TyCo.Rep.html#HoleCo"><span class="hs-identifier hs-var">HoleCo</span></a></span><span> </span><span class="annot"><span class="annottext">(CoercionHole -&gt; Coercion) -&gt; CoercionHole -&gt; Coercion
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="annot"><span class="annottext">CoercionHole -&gt; CoercionHole
</span><a href="#local-6989586621680854768"><span class="hs-identifier hs-var">go_hole</span></a></span><span> </span><span class="annot"><span class="annottext">CoercionHole
</span><a href="#local-6989586621680854769"><span class="hs-identifier hs-var">h</span></a></span><span>
</span><span id="line-844"></span><span>
</span><span id="line-845"></span><span>    </span><span id="local-6989586621680854794"><span class="annot"><span class="annottext">go_prov :: UnivCoProvenance -&gt; UnivCoProvenance
</span><a href="#local-6989586621680854794"><span class="hs-identifier hs-var hs-var">go_prov</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#PhantomProv"><span class="hs-identifier hs-type">PhantomProv</span></a></span><span> </span><span id="local-6989586621680854766"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854766"><span class="hs-identifier hs-var">kco</span></a></span></span><span class="hs-special">)</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; UnivCoProvenance
</span><a href="GHC.Core.TyCo.Rep.html#PhantomProv"><span class="hs-identifier hs-var">PhantomProv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="#local-6989586621680854839"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854766"><span class="hs-identifier hs-var">kco</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-846"></span><span>    </span><span class="annot"><a href="#local-6989586621680854794"><span class="hs-identifier hs-var">go_prov</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ProofIrrelProv"><span class="hs-identifier hs-type">ProofIrrelProv</span></a></span><span> </span><span id="local-6989586621680854764"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854764"><span class="hs-identifier hs-var">kco</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; UnivCoProvenance
</span><a href="GHC.Core.TyCo.Rep.html#ProofIrrelProv"><span class="hs-identifier hs-var">ProofIrrelProv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="#local-6989586621680854839"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854764"><span class="hs-identifier hs-var">kco</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-847"></span><span>    </span><span class="annot"><a href="#local-6989586621680854794"><span class="hs-identifier hs-var">go_prov</span></a></span><span> </span><span id="local-6989586621680854763"><span class="annot"><span class="annottext">p :: UnivCoProvenance
</span><a href="#local-6989586621680854763"><span class="hs-identifier hs-var">p</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#PluginProv"><span class="hs-identifier hs-type">PluginProv</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UnivCoProvenance
</span><a href="#local-6989586621680854763"><span class="hs-identifier hs-var">p</span></a></span><span>
</span><span id="line-848"></span><span>    </span><span class="annot"><a href="#local-6989586621680854794"><span class="hs-identifier hs-var">go_prov</span></a></span><span> </span><span id="local-6989586621680854761"><span class="annot"><span class="annottext">p :: UnivCoProvenance
</span><a href="#local-6989586621680854761"><span class="hs-identifier hs-var">p</span></a></span></span><span class="hs-glyph">@</span><span class="annot"><span class="annottext">UnivCoProvenance
</span><a href="GHC.Core.TyCo.Rep.html#CorePrepProv"><span class="hs-identifier hs-var">CorePrepProv</span></a></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UnivCoProvenance
</span><a href="#local-6989586621680854761"><span class="hs-identifier hs-var">p</span></a></span><span>
</span><span id="line-849"></span><span>
</span><span id="line-850"></span><span>    </span><span class="hs-comment">-- See Note [Substituting in a coercion hole]</span><span>
</span><span id="line-851"></span><span>    </span><span id="local-6989586621680854768"><span class="annot"><span class="annottext">go_hole :: CoercionHole -&gt; CoercionHole
</span><a href="#local-6989586621680854768"><span class="hs-identifier hs-var hs-var">go_hole</span></a></span></span><span> </span><span id="local-6989586621680854759"><span class="annot"><span class="annottext">h :: CoercionHole
</span><a href="#local-6989586621680854759"><span class="hs-identifier hs-var">h</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CoercionHole"><span class="hs-identifier hs-type">CoercionHole</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ch_co_var :: CoercionHole -&gt; TyCoVar
</span><a href="GHC.Core.TyCo.Rep.html#ch_co_var"><span class="hs-identifier hs-var">ch_co_var</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680854756"><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854756"><span class="hs-identifier hs-var">cv</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-852"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoercionHole
</span><a href="#local-6989586621680854759"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ch_co_var :: TyCoVar
</span><a href="GHC.Core.TyCo.Rep.html#ch_co_var"><span class="hs-identifier hs-var">ch_co_var</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Type -&gt; Type) -&gt; TyCoVar -&gt; TyCoVar
</span><a href="GHC.Types.Var.html#updateVarType"><span class="hs-identifier hs-var">updateVarType</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Type
</span><a href="#local-6989586621680854838"><span class="hs-identifier hs-var">go_ty</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854756"><span class="hs-identifier hs-var">cv</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-853"></span><span>
</span><span id="line-854"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substForAllCoBndr"><span class="hs-identifier hs-type">substForAllCoBndr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#KindCoercion"><span class="hs-identifier hs-type">KindCoercion</span></a></span><span>
</span><span id="line-855"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-856"></span><span id="substForAllCoBndr"><span class="annot"><span class="annottext">substForAllCoBndr :: TCvSubst -&gt; TyCoVar -&gt; Coercion -&gt; (TCvSubst, TyCoVar, Coercion)
</span><a href="GHC.Core.TyCo.Subst.html#substForAllCoBndr"><span class="hs-identifier hs-var hs-var">substForAllCoBndr</span></a></span></span><span> </span><span id="local-6989586621680854753"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854753"><span class="hs-identifier hs-var">subst</span></a></span></span><span>
</span><span id="line-857"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
-&gt; (Coercion -&gt; Coercion)
-&gt; TCvSubst
-&gt; TyCoVar
-&gt; Coercion
-&gt; (TCvSubst, TyCoVar, Coercion)
</span><a href="GHC.Core.TyCo.Subst.html#substForAllCoBndrUsing"><span class="hs-identifier hs-var">substForAllCoBndrUsing</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; Coercion -&gt; Coercion
TCvSubst -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.TyCo.Subst.html#substCo"><span class="hs-identifier hs-var">substCo</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854753"><span class="hs-identifier hs-var">subst</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854753"><span class="hs-identifier hs-var">subst</span></a></span><span>
</span><span id="line-858"></span><span>
</span><span id="line-859"></span><span class="hs-comment">-- | Like 'substForAllCoBndr', but disables sanity checks.</span><span>
</span><span id="line-860"></span><span class="hs-comment">-- The problems that the sanity checks in substCo catch are described in</span><span>
</span><span id="line-861"></span><span class="hs-comment">-- Note [The substitution invariant].</span><span>
</span><span id="line-862"></span><span class="hs-comment">-- The goal of #11371 is to migrate all the calls of substCoUnchecked to</span><span>
</span><span id="line-863"></span><span class="hs-comment">-- substCo and remove this function. Please don't use in new code.</span><span>
</span><span id="line-864"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substForAllCoBndrUnchecked"><span class="hs-identifier hs-type">substForAllCoBndrUnchecked</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#KindCoercion"><span class="hs-identifier hs-type">KindCoercion</span></a></span><span>
</span><span id="line-865"></span><span>                           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-866"></span><span id="substForAllCoBndrUnchecked"><span class="annot"><span class="annottext">substForAllCoBndrUnchecked :: TCvSubst -&gt; TyCoVar -&gt; Coercion -&gt; (TCvSubst, TyCoVar, Coercion)
</span><a href="GHC.Core.TyCo.Subst.html#substForAllCoBndrUnchecked"><span class="hs-identifier hs-var hs-var">substForAllCoBndrUnchecked</span></a></span></span><span> </span><span id="local-6989586621680854752"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854752"><span class="hs-identifier hs-var">subst</span></a></span></span><span>
</span><span id="line-867"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
-&gt; (Coercion -&gt; Coercion)
-&gt; TCvSubst
-&gt; TyCoVar
-&gt; Coercion
-&gt; (TCvSubst, TyCoVar, Coercion)
</span><a href="GHC.Core.TyCo.Subst.html#substForAllCoBndrUsing"><span class="hs-identifier hs-var">substForAllCoBndrUsing</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.TyCo.Subst.html#substCoUnchecked"><span class="hs-identifier hs-var">substCoUnchecked</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854752"><span class="hs-identifier hs-var">subst</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854752"><span class="hs-identifier hs-var">subst</span></a></span><span>
</span><span id="line-868"></span><span>
</span><span id="line-869"></span><span class="hs-comment">-- See Note [Sym and ForAllCo]</span><span>
</span><span id="line-870"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substForAllCoBndrUsing"><span class="hs-identifier hs-type">substForAllCoBndrUsing</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>  </span><span class="hs-comment">-- apply sym to binder?</span><span>
</span><span id="line-871"></span><span>                       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- transformation to kind co</span><span>
</span><span id="line-872"></span><span>                       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#KindCoercion"><span class="hs-identifier hs-type">KindCoercion</span></a></span><span>
</span><span id="line-873"></span><span>                       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#KindCoercion"><span class="hs-identifier hs-type">KindCoercion</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-874"></span><span id="substForAllCoBndrUsing"><span class="annot"><span class="annottext">substForAllCoBndrUsing :: Bool
-&gt; (Coercion -&gt; Coercion)
-&gt; TCvSubst
-&gt; TyCoVar
-&gt; Coercion
-&gt; (TCvSubst, TyCoVar, Coercion)
</span><a href="GHC.Core.TyCo.Subst.html#substForAllCoBndrUsing"><span class="hs-identifier hs-var hs-var">substForAllCoBndrUsing</span></a></span></span><span> </span><span id="local-6989586621680854751"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680854751"><span class="hs-identifier hs-var">sym</span></a></span></span><span> </span><span id="local-6989586621680854750"><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="#local-6989586621680854750"><span class="hs-identifier hs-var">sco</span></a></span></span><span> </span><span id="local-6989586621680854749"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854749"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680854748"><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854748"><span class="hs-identifier hs-var">old_var</span></a></span></span><span>
</span><span id="line-875"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCoVar -&gt; Bool
</span><a href="GHC.Types.Var.html#isTyVar"><span class="hs-identifier hs-var">isTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854748"><span class="hs-identifier hs-var">old_var</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
-&gt; (Coercion -&gt; Coercion)
-&gt; TCvSubst
-&gt; TyCoVar
-&gt; Coercion
-&gt; (TCvSubst, TyCoVar, Coercion)
</span><a href="GHC.Core.TyCo.Subst.html#substForAllCoTyVarBndrUsing"><span class="hs-identifier hs-var">substForAllCoTyVarBndrUsing</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680854751"><span class="hs-identifier hs-var">sym</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="#local-6989586621680854750"><span class="hs-identifier hs-var">sco</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854749"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854748"><span class="hs-identifier hs-var">old_var</span></a></span><span>
</span><span id="line-876"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
-&gt; (Coercion -&gt; Coercion)
-&gt; TCvSubst
-&gt; TyCoVar
-&gt; Coercion
-&gt; (TCvSubst, TyCoVar, Coercion)
</span><a href="GHC.Core.TyCo.Subst.html#substForAllCoCoVarBndrUsing"><span class="hs-identifier hs-var">substForAllCoCoVarBndrUsing</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680854751"><span class="hs-identifier hs-var">sym</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="#local-6989586621680854750"><span class="hs-identifier hs-var">sco</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854749"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854748"><span class="hs-identifier hs-var">old_var</span></a></span><span>
</span><span id="line-877"></span><span>
</span><span id="line-878"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substForAllCoTyVarBndrUsing"><span class="hs-identifier hs-type">substForAllCoTyVarBndrUsing</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>  </span><span class="hs-comment">-- apply sym to binder?</span><span>
</span><span id="line-879"></span><span>                            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- transformation to kind co</span><span>
</span><span id="line-880"></span><span>                            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#KindCoercion"><span class="hs-identifier hs-type">KindCoercion</span></a></span><span>
</span><span id="line-881"></span><span>                            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#KindCoercion"><span class="hs-identifier hs-type">KindCoercion</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-882"></span><span id="substForAllCoTyVarBndrUsing"><span class="annot"><span class="annottext">substForAllCoTyVarBndrUsing :: Bool
-&gt; (Coercion -&gt; Coercion)
-&gt; TCvSubst
-&gt; TyCoVar
-&gt; Coercion
-&gt; (TCvSubst, TyCoVar, Coercion)
</span><a href="GHC.Core.TyCo.Subst.html#substForAllCoTyVarBndrUsing"><span class="hs-identifier hs-var hs-var">substForAllCoTyVarBndrUsing</span></a></span></span><span> </span><span id="local-6989586621680854745"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680854745"><span class="hs-identifier hs-var">sym</span></a></span></span><span> </span><span id="local-6989586621680854744"><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="#local-6989586621680854744"><span class="hs-identifier hs-var">sco</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span id="local-6989586621680854743"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680854743"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680854742"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854742"><span class="hs-identifier hs-var">tenv</span></a></span></span><span> </span><span id="local-6989586621680854741"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680854741"><span class="hs-identifier hs-var">cenv</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680854740"><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854740"><span class="hs-identifier hs-var">old_var</span></a></span></span><span> </span><span id="local-6989586621680854739"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854739"><span class="hs-identifier hs-var">old_kind_co</span></a></span></span><span>
</span><span id="line-883"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isTyVar</span><span> </span><span class="hs-identifier">old_var</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-884"></span><span>    </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-var">TCvSubst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680854743"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TyCoVar -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#extendInScopeSet"><span class="hs-operator hs-var">`extendInScopeSet`</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854738"><span class="hs-identifier hs-var">new_var</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854737"><span class="hs-identifier hs-var">new_env</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680854741"><span class="hs-identifier hs-var">cenv</span></a></span><span>
</span><span id="line-885"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854738"><span class="hs-identifier hs-var">new_var</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854736"><span class="hs-identifier hs-var">new_kind_co</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-886"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-887"></span><span>    </span><span id="local-6989586621680854737"><span class="annot"><span class="annottext">new_env :: TvSubstEnv
</span><a href="#local-6989586621680854737"><span class="hs-identifier hs-var hs-var">new_env</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680854735"><span class="hs-identifier hs-var">no_change</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680854745"><span class="hs-identifier hs-var">sym</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv -&gt; TyCoVar -&gt; TvSubstEnv
forall a. VarEnv a -&gt; TyCoVar -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#delVarEnv"><span class="hs-identifier hs-var">delVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854742"><span class="hs-identifier hs-var">tenv</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854740"><span class="hs-identifier hs-var">old_var</span></a></span><span>
</span><span id="line-888"></span><span>            </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680854745"><span class="hs-identifier hs-var">sym</span></a></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv -&gt; TyCoVar -&gt; Type -&gt; TvSubstEnv
forall a. VarEnv a -&gt; TyCoVar -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnv"><span class="hs-identifier hs-var">extendVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854742"><span class="hs-identifier hs-var">tenv</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854740"><span class="hs-identifier hs-var">old_var</span></a></span><span> </span><span class="annot"><span class="annottext">(Type -&gt; TvSubstEnv) -&gt; Type -&gt; TvSubstEnv
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-889"></span><span>                          </span><span class="annot"><span class="annottext">TyCoVar -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#TyVarTy"><span class="hs-identifier hs-var">TyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854738"><span class="hs-identifier hs-var">new_var</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Coercion -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#CastTy"><span class="hs-operator hs-var">`CastTy`</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854736"><span class="hs-identifier hs-var">new_kind_co</span></a></span><span>
</span><span id="line-890"></span><span>            </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv -&gt; TyCoVar -&gt; Type -&gt; TvSubstEnv
forall a. VarEnv a -&gt; TyCoVar -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnv"><span class="hs-identifier hs-var">extendVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854742"><span class="hs-identifier hs-var">tenv</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854740"><span class="hs-identifier hs-var">old_var</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCoVar -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#TyVarTy"><span class="hs-identifier hs-var">TyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854738"><span class="hs-identifier hs-var">new_var</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-891"></span><span>
</span><span id="line-892"></span><span>    </span><span id="local-6989586621680854733"><span class="annot"><span class="annottext">no_kind_change :: Bool
</span><a href="#local-6989586621680854733"><span class="hs-identifier hs-var hs-var">no_kind_change</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Bool
</span><a href="GHC.Core.TyCo.FVs.html#noFreeVarsOfCo"><span class="hs-identifier hs-var">noFreeVarsOfCo</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854739"><span class="hs-identifier hs-var">old_kind_co</span></a></span><span>
</span><span id="line-893"></span><span>    </span><span id="local-6989586621680854735"><span class="annot"><span class="annottext">no_change :: Bool
</span><a href="#local-6989586621680854735"><span class="hs-identifier hs-var hs-var">no_change</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680854733"><span class="hs-identifier hs-var">no_kind_change</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854738"><span class="hs-identifier hs-var">new_var</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar -&gt; TyCoVar -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854740"><span class="hs-identifier hs-var">old_var</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-894"></span><span>
</span><span id="line-895"></span><span>    </span><span id="local-6989586621680854736"><span class="annot"><span class="annottext">new_kind_co :: Coercion
</span><a href="#local-6989586621680854736"><span class="hs-identifier hs-var hs-var">new_kind_co</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680854733"><span class="hs-identifier hs-var">no_kind_change</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854739"><span class="hs-identifier hs-var">old_kind_co</span></a></span><span>
</span><span id="line-896"></span><span>                </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="#local-6989586621680854744"><span class="hs-identifier hs-var">sco</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854739"><span class="hs-identifier hs-var">old_kind_co</span></a></span><span>
</span><span id="line-897"></span><span>
</span><span id="line-898"></span><span>    </span><span id="local-6989586621680854729"><span class="annot"><span class="annottext">new_ki1 :: Type
</span><a href="#local-6989586621680854729"><span class="hs-identifier hs-var hs-var">new_ki1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Type
</span><a href="GHC.Core.Coercion.html#coercionLKind"><span class="hs-identifier hs-var">coercionLKind</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854736"><span class="hs-identifier hs-var">new_kind_co</span></a></span><span>
</span><span id="line-899"></span><span>    </span><span class="hs-comment">-- We could do substitution to (tyVarKind old_var). We don't do so because</span><span>
</span><span id="line-900"></span><span>    </span><span class="hs-comment">-- we already substituted new_kind_co, which contains the kind information</span><span>
</span><span id="line-901"></span><span>    </span><span class="hs-comment">-- we want. We don't want to do substitution once more. Also, in most cases,</span><span>
</span><span id="line-902"></span><span>    </span><span class="hs-comment">-- new_kind_co is a Refl, in which case coercionKind is really fast.</span><span>
</span><span id="line-903"></span><span>
</span><span id="line-904"></span><span>    </span><span id="local-6989586621680854738"><span class="annot"><span class="annottext">new_var :: TyCoVar
</span><a href="#local-6989586621680854738"><span class="hs-identifier hs-var hs-var">new_var</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TyCoVar -&gt; TyCoVar
</span><a href="GHC.Types.Var.Env.html#uniqAway"><span class="hs-identifier hs-var">uniqAway</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680854743"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCoVar -&gt; Type -&gt; TyCoVar
</span><a href="GHC.Types.Var.html#setTyVarKind"><span class="hs-identifier hs-var">setTyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854740"><span class="hs-identifier hs-var">old_var</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854729"><span class="hs-identifier hs-var">new_ki1</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-905"></span><span>
</span><span id="line-906"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substForAllCoCoVarBndrUsing"><span class="hs-identifier hs-type">substForAllCoCoVarBndrUsing</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>  </span><span class="hs-comment">-- apply sym to binder?</span><span>
</span><span id="line-907"></span><span>                            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- transformation to kind co</span><span>
</span><span id="line-908"></span><span>                            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#CoVar"><span class="hs-identifier hs-type">CoVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#KindCoercion"><span class="hs-identifier hs-type">KindCoercion</span></a></span><span>
</span><span id="line-909"></span><span>                            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#CoVar"><span class="hs-identifier hs-type">CoVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#KindCoercion"><span class="hs-identifier hs-type">KindCoercion</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-910"></span><span id="substForAllCoCoVarBndrUsing"><span class="annot"><span class="annottext">substForAllCoCoVarBndrUsing :: Bool
-&gt; (Coercion -&gt; Coercion)
-&gt; TCvSubst
-&gt; TyCoVar
-&gt; Coercion
-&gt; (TCvSubst, TyCoVar, Coercion)
</span><a href="GHC.Core.TyCo.Subst.html#substForAllCoCoVarBndrUsing"><span class="hs-identifier hs-var hs-var">substForAllCoCoVarBndrUsing</span></a></span></span><span> </span><span id="local-6989586621680854726"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680854726"><span class="hs-identifier hs-var">sym</span></a></span></span><span> </span><span id="local-6989586621680854725"><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="#local-6989586621680854725"><span class="hs-identifier hs-var">sco</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span id="local-6989586621680854724"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680854724"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680854723"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854723"><span class="hs-identifier hs-var">tenv</span></a></span></span><span> </span><span id="local-6989586621680854722"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680854722"><span class="hs-identifier hs-var">cenv</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-911"></span><span>                            </span><span id="local-6989586621680854721"><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854721"><span class="hs-identifier hs-var">old_var</span></a></span></span><span> </span><span id="local-6989586621680854720"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854720"><span class="hs-identifier hs-var">old_kind_co</span></a></span></span><span>
</span><span id="line-912"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isCoVar</span><span> </span><span class="hs-identifier">old_var</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-913"></span><span>    </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-var">TCvSubst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680854724"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TyCoVar -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#extendInScopeSet"><span class="hs-operator hs-var">`extendInScopeSet`</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854719"><span class="hs-identifier hs-var">new_var</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854723"><span class="hs-identifier hs-var">tenv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680854718"><span class="hs-identifier hs-var">new_cenv</span></a></span><span>
</span><span id="line-914"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854719"><span class="hs-identifier hs-var">new_var</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854717"><span class="hs-identifier hs-var">new_kind_co</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-915"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-916"></span><span>    </span><span id="local-6989586621680854718"><span class="annot"><span class="annottext">new_cenv :: CvSubstEnv
</span><a href="#local-6989586621680854718"><span class="hs-identifier hs-var hs-var">new_cenv</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680854716"><span class="hs-identifier hs-var">no_change</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680854726"><span class="hs-identifier hs-var">sym</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv -&gt; TyCoVar -&gt; CvSubstEnv
forall a. VarEnv a -&gt; TyCoVar -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#delVarEnv"><span class="hs-identifier hs-var">delVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680854722"><span class="hs-identifier hs-var">cenv</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854721"><span class="hs-identifier hs-var">old_var</span></a></span><span>
</span><span id="line-917"></span><span>             </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv -&gt; TyCoVar -&gt; Coercion -&gt; CvSubstEnv
forall a. VarEnv a -&gt; TyCoVar -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnv"><span class="hs-identifier hs-var">extendVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680854722"><span class="hs-identifier hs-var">cenv</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854721"><span class="hs-identifier hs-var">old_var</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCoVar -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkCoVarCo"><span class="hs-identifier hs-var">mkCoVarCo</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854719"><span class="hs-identifier hs-var">new_var</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-918"></span><span>
</span><span id="line-919"></span><span>    </span><span id="local-6989586621680854715"><span class="annot"><span class="annottext">no_kind_change :: Bool
</span><a href="#local-6989586621680854715"><span class="hs-identifier hs-var hs-var">no_kind_change</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Bool
</span><a href="GHC.Core.TyCo.FVs.html#noFreeVarsOfCo"><span class="hs-identifier hs-var">noFreeVarsOfCo</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854720"><span class="hs-identifier hs-var">old_kind_co</span></a></span><span>
</span><span id="line-920"></span><span>    </span><span id="local-6989586621680854716"><span class="annot"><span class="annottext">no_change :: Bool
</span><a href="#local-6989586621680854716"><span class="hs-identifier hs-var hs-var">no_change</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680854715"><span class="hs-identifier hs-var">no_kind_change</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854719"><span class="hs-identifier hs-var">new_var</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar -&gt; TyCoVar -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854721"><span class="hs-identifier hs-var">old_var</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-921"></span><span>
</span><span id="line-922"></span><span>    </span><span id="local-6989586621680854717"><span class="annot"><span class="annottext">new_kind_co :: Coercion
</span><a href="#local-6989586621680854717"><span class="hs-identifier hs-var hs-var">new_kind_co</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680854715"><span class="hs-identifier hs-var">no_kind_change</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854720"><span class="hs-identifier hs-var">old_kind_co</span></a></span><span>
</span><span id="line-923"></span><span>                </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="#local-6989586621680854725"><span class="hs-identifier hs-var">sco</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854720"><span class="hs-identifier hs-var">old_kind_co</span></a></span><span>
</span><span id="line-924"></span><span>
</span><span id="line-925"></span><span>    </span><span class="annot"><a href="GHC.Data.Pair.html#Pair"><span class="hs-identifier hs-type">Pair</span></a></span><span> </span><span id="local-6989586621680854712"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854712"><span class="hs-identifier hs-var">h1</span></a></span></span><span> </span><span id="local-6989586621680854711"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854711"><span class="hs-identifier hs-var">h2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Pair Type
</span><a href="GHC.Core.Coercion.html#coercionKind"><span class="hs-identifier hs-var">coercionKind</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854717"><span class="hs-identifier hs-var">new_kind_co</span></a></span><span>
</span><span id="line-926"></span><span>
</span><span id="line-927"></span><span>    </span><span id="local-6989586621680854719"><span class="annot"><span class="annottext">new_var :: TyCoVar
</span><a href="#local-6989586621680854719"><span class="hs-identifier hs-var hs-var">new_var</span></a></span></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TyCoVar -&gt; TyCoVar
</span><a href="GHC.Types.Var.Env.html#uniqAway"><span class="hs-identifier hs-var">uniqAway</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680854724"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">(TyCoVar -&gt; TyCoVar) -&gt; TyCoVar -&gt; TyCoVar
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; Type -&gt; TyCoVar
</span><a href="GHC.Types.Var.html#mkCoVar"><span class="hs-identifier hs-var">mkCoVar</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCoVar -&gt; Name
</span><a href="GHC.Types.Var.html#varName"><span class="hs-identifier hs-var hs-var">varName</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854721"><span class="hs-identifier hs-var">old_var</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854708"><span class="hs-identifier hs-var">new_var_type</span></a></span><span>
</span><span id="line-928"></span><span>    </span><span id="local-6989586621680854708"><span class="annot"><span class="annottext">new_var_type :: Type
</span><a href="#local-6989586621680854708"><span class="hs-identifier hs-var hs-var">new_var_type</span></a></span></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680854726"><span class="hs-identifier hs-var">sym</span></a></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854711"><span class="hs-identifier hs-var">h2</span></a></span><span>
</span><span id="line-929"></span><span>                  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854712"><span class="hs-identifier hs-var">h1</span></a></span><span>
</span><span id="line-930"></span><span>
</span><span id="line-931"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substCoVar"><span class="hs-identifier hs-type">substCoVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#CoVar"><span class="hs-identifier hs-type">CoVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span>
</span><span id="line-932"></span><span id="substCoVar"><span class="annot"><span class="annottext">substCoVar :: TCvSubst -&gt; TyCoVar -&gt; Coercion
</span><a href="GHC.Core.TyCo.Subst.html#substCoVar"><span class="hs-identifier hs-var hs-var">substCoVar</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680854707"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680854707"><span class="hs-identifier hs-var">cenv</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680854706"><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854706"><span class="hs-identifier hs-var">cv</span></a></span></span><span>
</span><span id="line-933"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv -&gt; TyCoVar -&gt; Maybe Coercion
forall a. VarEnv a -&gt; TyCoVar -&gt; Maybe a
</span><a href="GHC.Types.Var.Env.html#lookupVarEnv"><span class="hs-identifier hs-var">lookupVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680854707"><span class="hs-identifier hs-var">cenv</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854706"><span class="hs-identifier hs-var">cv</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-934"></span><span>      </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680854705"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854705"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854705"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-935"></span><span>      </span><span class="annot"><span class="annottext">Maybe Coercion
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TyCoVar -&gt; Coercion
</span><a href="GHC.Core.TyCo.Rep.html#CoVarCo"><span class="hs-identifier hs-var">CoVarCo</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854706"><span class="hs-identifier hs-var">cv</span></a></span><span>
</span><span id="line-936"></span><span>
</span><span id="line-937"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substCoVars"><span class="hs-identifier hs-type">substCoVars</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#CoVar"><span class="hs-identifier hs-type">CoVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-938"></span><span id="substCoVars"><span class="annot"><span class="annottext">substCoVars :: TCvSubst -&gt; [TyCoVar] -&gt; [Coercion]
</span><a href="GHC.Core.TyCo.Subst.html#substCoVars"><span class="hs-identifier hs-var hs-var">substCoVars</span></a></span></span><span> </span><span id="local-6989586621680854704"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854704"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680854703"><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680854703"><span class="hs-identifier hs-var">cvs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TyCoVar -&gt; Coercion) -&gt; [TyCoVar] -&gt; [Coercion]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst -&gt; TyCoVar -&gt; Coercion
</span><a href="GHC.Core.TyCo.Subst.html#substCoVar"><span class="hs-identifier hs-var">substCoVar</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854704"><span class="hs-identifier hs-var">subst</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680854703"><span class="hs-identifier hs-var">cvs</span></a></span><span>
</span><span id="line-939"></span><span>
</span><span id="line-940"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#lookupCoVar"><span class="hs-identifier hs-type">lookupCoVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span>
</span><span id="line-941"></span><span id="lookupCoVar"><span class="annot"><span class="annottext">lookupCoVar :: TCvSubst -&gt; TyCoVar -&gt; Maybe Coercion
</span><a href="GHC.Core.TyCo.Subst.html#lookupCoVar"><span class="hs-identifier hs-var hs-var">lookupCoVar</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680854702"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680854702"><span class="hs-identifier hs-var">cenv</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680854701"><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854701"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv -&gt; TyCoVar -&gt; Maybe Coercion
forall a. VarEnv a -&gt; TyCoVar -&gt; Maybe a
</span><a href="GHC.Types.Var.Env.html#lookupVarEnv"><span class="hs-identifier hs-var">lookupVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680854702"><span class="hs-identifier hs-var">cenv</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854701"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-942"></span><span>
</span><span id="line-943"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTyVarBndr"><span class="hs-identifier hs-type">substTyVarBndr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Stack.Types.html#HasCallStack"><span class="hs-identifier hs-type">HasCallStack</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-944"></span><span id="substTyVarBndr"><span class="annot"><span class="annottext">substTyVarBndr :: HasCallStack =&gt; TCvSubst -&gt; TyCoVar -&gt; (TCvSubst, TyCoVar)
</span><a href="GHC.Core.TyCo.Subst.html#substTyVarBndr"><span class="hs-identifier hs-var hs-var">substTyVarBndr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TCvSubst -&gt; Type -&gt; Type)
-&gt; TCvSubst -&gt; TyCoVar -&gt; (TCvSubst, TyCoVar)
</span><a href="GHC.Core.TyCo.Subst.html#substTyVarBndrUsing"><span class="hs-identifier hs-var">substTyVarBndrUsing</span></a></span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; Type -&gt; Type
TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTy"><span class="hs-identifier hs-var">substTy</span></a></span><span>
</span><span id="line-945"></span><span>
</span><span id="line-946"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTyVarBndrs"><span class="hs-identifier hs-type">substTyVarBndrs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Stack.Types.html#HasCallStack"><span class="hs-identifier hs-type">HasCallStack</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-947"></span><span id="substTyVarBndrs"><span class="annot"><span class="annottext">substTyVarBndrs :: HasCallStack =&gt; TCvSubst -&gt; [TyCoVar] -&gt; (TCvSubst, [TyCoVar])
</span><a href="GHC.Core.TyCo.Subst.html#substTyVarBndrs"><span class="hs-identifier hs-var hs-var">substTyVarBndrs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TCvSubst -&gt; TyCoVar -&gt; (TCvSubst, TyCoVar))
-&gt; TCvSubst -&gt; [TyCoVar] -&gt; (TCvSubst, [TyCoVar])
forall (t :: * -&gt; *) s a b.
Traversable t =&gt;
(s -&gt; a -&gt; (s, b)) -&gt; s -&gt; t a -&gt; (s, t b)
</span><a href="../../base/src/Data.Traversable.html#mapAccumL"><span class="hs-identifier hs-var">mapAccumL</span></a></span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; TyCoVar -&gt; (TCvSubst, TyCoVar)
TCvSubst -&gt; TyCoVar -&gt; (TCvSubst, TyCoVar)
</span><a href="GHC.Core.TyCo.Subst.html#substTyVarBndr"><span class="hs-identifier hs-var">substTyVarBndr</span></a></span><span>
</span><span id="line-948"></span><span>
</span><span id="line-949"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substVarBndr"><span class="hs-identifier hs-type">substVarBndr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Stack.Types.html#HasCallStack"><span class="hs-identifier hs-type">HasCallStack</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-950"></span><span id="substVarBndr"><span class="annot"><span class="annottext">substVarBndr :: HasCallStack =&gt; TCvSubst -&gt; TyCoVar -&gt; (TCvSubst, TyCoVar)
</span><a href="GHC.Core.TyCo.Subst.html#substVarBndr"><span class="hs-identifier hs-var hs-var">substVarBndr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TCvSubst -&gt; Type -&gt; Type)
-&gt; TCvSubst -&gt; TyCoVar -&gt; (TCvSubst, TyCoVar)
</span><a href="GHC.Core.TyCo.Subst.html#substVarBndrUsing"><span class="hs-identifier hs-var">substVarBndrUsing</span></a></span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; Type -&gt; Type
TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTy"><span class="hs-identifier hs-var">substTy</span></a></span><span>
</span><span id="line-951"></span><span>
</span><span id="line-952"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substVarBndrs"><span class="hs-identifier hs-type">substVarBndrs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Stack.Types.html#HasCallStack"><span class="hs-identifier hs-type">HasCallStack</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-953"></span><span id="substVarBndrs"><span class="annot"><span class="annottext">substVarBndrs :: HasCallStack =&gt; TCvSubst -&gt; [TyCoVar] -&gt; (TCvSubst, [TyCoVar])
</span><a href="GHC.Core.TyCo.Subst.html#substVarBndrs"><span class="hs-identifier hs-var hs-var">substVarBndrs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TCvSubst -&gt; TyCoVar -&gt; (TCvSubst, TyCoVar))
-&gt; TCvSubst -&gt; [TyCoVar] -&gt; (TCvSubst, [TyCoVar])
forall (t :: * -&gt; *) s a b.
Traversable t =&gt;
(s -&gt; a -&gt; (s, b)) -&gt; s -&gt; t a -&gt; (s, t b)
</span><a href="../../base/src/Data.Traversable.html#mapAccumL"><span class="hs-identifier hs-var">mapAccumL</span></a></span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; TyCoVar -&gt; (TCvSubst, TyCoVar)
TCvSubst -&gt; TyCoVar -&gt; (TCvSubst, TyCoVar)
</span><a href="GHC.Core.TyCo.Subst.html#substVarBndr"><span class="hs-identifier hs-var">substVarBndr</span></a></span><span>
</span><span id="line-954"></span><span>
</span><span id="line-955"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substCoVarBndr"><span class="hs-identifier hs-type">substCoVarBndr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Stack.Types.html#HasCallStack"><span class="hs-identifier hs-type">HasCallStack</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#CoVar"><span class="hs-identifier hs-type">CoVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#CoVar"><span class="hs-identifier hs-type">CoVar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-956"></span><span id="substCoVarBndr"><span class="annot"><span class="annottext">substCoVarBndr :: HasCallStack =&gt; TCvSubst -&gt; TyCoVar -&gt; (TCvSubst, TyCoVar)
</span><a href="GHC.Core.TyCo.Subst.html#substCoVarBndr"><span class="hs-identifier hs-var hs-var">substCoVarBndr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TCvSubst -&gt; Type -&gt; Type)
-&gt; TCvSubst -&gt; TyCoVar -&gt; (TCvSubst, TyCoVar)
</span><a href="GHC.Core.TyCo.Subst.html#substCoVarBndrUsing"><span class="hs-identifier hs-var">substCoVarBndrUsing</span></a></span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; Type -&gt; Type
TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTy"><span class="hs-identifier hs-var">substTy</span></a></span><span>
</span><span id="line-957"></span><span>
</span><span id="line-958"></span><span class="hs-comment">-- | Like 'substVarBndr', but disables sanity checks.</span><span>
</span><span id="line-959"></span><span class="hs-comment">-- The problems that the sanity checks in substTy catch are described in</span><span>
</span><span id="line-960"></span><span class="hs-comment">-- Note [The substitution invariant].</span><span>
</span><span id="line-961"></span><span class="hs-comment">-- The goal of #11371 is to migrate all the calls of substTyUnchecked to</span><span>
</span><span id="line-962"></span><span class="hs-comment">-- substTy and remove this function. Please don't use in new code.</span><span>
</span><span id="line-963"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substVarBndrUnchecked"><span class="hs-identifier hs-type">substVarBndrUnchecked</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-964"></span><span id="substVarBndrUnchecked"><span class="annot"><span class="annottext">substVarBndrUnchecked :: TCvSubst -&gt; TyCoVar -&gt; (TCvSubst, TyCoVar)
</span><a href="GHC.Core.TyCo.Subst.html#substVarBndrUnchecked"><span class="hs-identifier hs-var hs-var">substVarBndrUnchecked</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TCvSubst -&gt; Type -&gt; Type)
-&gt; TCvSubst -&gt; TyCoVar -&gt; (TCvSubst, TyCoVar)
</span><a href="GHC.Core.TyCo.Subst.html#substVarBndrUsing"><span class="hs-identifier hs-var">substVarBndrUsing</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTyUnchecked"><span class="hs-identifier hs-var">substTyUnchecked</span></a></span><span>
</span><span id="line-965"></span><span>
</span><span id="line-966"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substVarBndrUsing"><span class="hs-identifier hs-type">substVarBndrUsing</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-967"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-968"></span><span id="substVarBndrUsing"><span class="annot"><span class="annottext">substVarBndrUsing :: (TCvSubst -&gt; Type -&gt; Type)
-&gt; TCvSubst -&gt; TyCoVar -&gt; (TCvSubst, TyCoVar)
</span><a href="GHC.Core.TyCo.Subst.html#substVarBndrUsing"><span class="hs-identifier hs-var hs-var">substVarBndrUsing</span></a></span></span><span> </span><span id="local-6989586621680854680"><span class="annot"><span class="annottext">TCvSubst -&gt; Type -&gt; Type
</span><a href="#local-6989586621680854680"><span class="hs-identifier hs-var">subst_fn</span></a></span></span><span> </span><span id="local-6989586621680854679"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854679"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680854678"><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854678"><span class="hs-identifier hs-var">v</span></a></span></span><span>
</span><span id="line-969"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCoVar -&gt; Bool
</span><a href="GHC.Types.Var.html#isTyVar"><span class="hs-identifier hs-var">isTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854678"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TCvSubst -&gt; Type -&gt; Type)
-&gt; TCvSubst -&gt; TyCoVar -&gt; (TCvSubst, TyCoVar)
</span><a href="GHC.Core.TyCo.Subst.html#substTyVarBndrUsing"><span class="hs-identifier hs-var">substTyVarBndrUsing</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; Type -&gt; Type
</span><a href="#local-6989586621680854680"><span class="hs-identifier hs-var">subst_fn</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854679"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854678"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-970"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TCvSubst -&gt; Type -&gt; Type)
-&gt; TCvSubst -&gt; TyCoVar -&gt; (TCvSubst, TyCoVar)
</span><a href="GHC.Core.TyCo.Subst.html#substCoVarBndrUsing"><span class="hs-identifier hs-var">substCoVarBndrUsing</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; Type -&gt; Type
</span><a href="#local-6989586621680854680"><span class="hs-identifier hs-var">subst_fn</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854679"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854678"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-971"></span><span>
</span><span id="line-972"></span><span class="hs-comment">-- | Substitute a tyvar in a binding position, returning an</span><span>
</span><span id="line-973"></span><span class="hs-comment">-- extended subst and a new tyvar.</span><span>
</span><span id="line-974"></span><span class="hs-comment">-- Use the supplied function to substitute in the kind</span><span>
</span><span id="line-975"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTyVarBndrUsing"><span class="hs-identifier hs-type">substTyVarBndrUsing</span></a></span><span>
</span><span id="line-976"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- ^ Use this to substitute in the kind</span><span>
</span><span id="line-977"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-978"></span><span id="substTyVarBndrUsing"><span class="annot"><span class="annottext">substTyVarBndrUsing :: (TCvSubst -&gt; Type -&gt; Type)
-&gt; TCvSubst -&gt; TyCoVar -&gt; (TCvSubst, TyCoVar)
</span><a href="GHC.Core.TyCo.Subst.html#substTyVarBndrUsing"><span class="hs-identifier hs-var hs-var">substTyVarBndrUsing</span></a></span></span><span> </span><span id="local-6989586621680854677"><span class="annot"><span class="annottext">TCvSubst -&gt; Type -&gt; Type
</span><a href="#local-6989586621680854677"><span class="hs-identifier hs-var">subst_fn</span></a></span></span><span> </span><span id="local-6989586621680854676"><span class="annot"><span class="annottext">subst :: TCvSubst
</span><a href="#local-6989586621680854676"><span class="hs-identifier hs-var">subst</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span id="local-6989586621680854675"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680854675"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680854674"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854674"><span class="hs-identifier hs-var">tenv</span></a></span></span><span> </span><span id="local-6989586621680854673"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680854673"><span class="hs-identifier hs-var">cenv</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680854672"><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854672"><span class="hs-identifier hs-var">old_var</span></a></span></span><span>
</span><span id="line-979"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT2</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">_no_capture</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">pprTyVar</span><span> </span><span class="hs-identifier">old_var</span><span> </span><span class="hs-operator">$$</span><span> </span><span class="hs-identifier">pprTyVar</span><span> </span><span class="hs-identifier">new_var</span><span> </span><span class="hs-operator">$$</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">subst</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-980"></span><span>    </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isTyVar</span><span> </span><span class="hs-identifier">old_var</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-981"></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-var">TCvSubst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680854675"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TyCoVar -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#extendInScopeSet"><span class="hs-operator hs-var">`extendInScopeSet`</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854670"><span class="hs-identifier hs-var">new_var</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854669"><span class="hs-identifier hs-var">new_env</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680854673"><span class="hs-identifier hs-var">cenv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854670"><span class="hs-identifier hs-var">new_var</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-982"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-983"></span><span>    </span><span id="local-6989586621680854669"><span class="annot"><span class="annottext">new_env :: TvSubstEnv
</span><a href="#local-6989586621680854669"><span class="hs-identifier hs-var hs-var">new_env</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680854668"><span class="hs-identifier hs-var">no_change</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv -&gt; TyCoVar -&gt; TvSubstEnv
forall a. VarEnv a -&gt; TyCoVar -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#delVarEnv"><span class="hs-identifier hs-var">delVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854674"><span class="hs-identifier hs-var">tenv</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854672"><span class="hs-identifier hs-var">old_var</span></a></span><span>
</span><span id="line-984"></span><span>            </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv -&gt; TyCoVar -&gt; Type -&gt; TvSubstEnv
forall a. VarEnv a -&gt; TyCoVar -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnv"><span class="hs-identifier hs-var">extendVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854674"><span class="hs-identifier hs-var">tenv</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854672"><span class="hs-identifier hs-var">old_var</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCoVar -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#TyVarTy"><span class="hs-identifier hs-var">TyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854670"><span class="hs-identifier hs-var">new_var</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-985"></span><span>
</span><span id="line-986"></span><span>    </span><span id="local-6989586621680854671"><span class="annot"><span class="annottext">_no_capture :: Bool
</span><a href="#local-6989586621680854671"><span class="hs-identifier hs-var hs-var">_no_capture</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854670"><span class="hs-identifier hs-var">new_var</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#elemVarSet"><span class="hs-operator hs-var">`elemVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#shallowTyCoVarsOfTyVarEnv"><span class="hs-identifier hs-var">shallowTyCoVarsOfTyVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854674"><span class="hs-identifier hs-var">tenv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-987"></span><span>    </span><span class="hs-comment">-- Assertion check that we are not capturing something in the substitution</span><span>
</span><span id="line-988"></span><span>
</span><span id="line-989"></span><span>    </span><span id="local-6989586621680854666"><span class="annot"><span class="annottext">old_ki :: Type
</span><a href="#local-6989586621680854666"><span class="hs-identifier hs-var hs-var">old_ki</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCoVar -&gt; Type
</span><a href="GHC.Types.Var.html#tyVarKind"><span class="hs-identifier hs-var">tyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854672"><span class="hs-identifier hs-var">old_var</span></a></span><span>
</span><span id="line-990"></span><span>    </span><span id="local-6989586621680854665"><span class="annot"><span class="annottext">no_kind_change :: Bool
</span><a href="#local-6989586621680854665"><span class="hs-identifier hs-var hs-var">no_kind_change</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Bool
</span><a href="GHC.Core.TyCo.FVs.html#noFreeVarsOfType"><span class="hs-identifier hs-var">noFreeVarsOfType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854666"><span class="hs-identifier hs-var">old_ki</span></a></span><span> </span><span class="hs-comment">-- verify that kind is closed</span><span>
</span><span id="line-991"></span><span>    </span><span id="local-6989586621680854668"><span class="annot"><span class="annottext">no_change :: Bool
</span><a href="#local-6989586621680854668"><span class="hs-identifier hs-var hs-var">no_change</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680854665"><span class="hs-identifier hs-var">no_kind_change</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854670"><span class="hs-identifier hs-var">new_var</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar -&gt; TyCoVar -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854672"><span class="hs-identifier hs-var">old_var</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-992"></span><span>        </span><span class="hs-comment">-- no_change means that the new_var is identical in</span><span>
</span><span id="line-993"></span><span>        </span><span class="hs-comment">-- all respects to the old_var (same unique, same kind)</span><span>
</span><span id="line-994"></span><span>        </span><span class="hs-comment">-- See Note [Extending the TCvSubst]</span><span>
</span><span id="line-995"></span><span>        </span><span class="hs-comment">--</span><span>
</span><span id="line-996"></span><span>        </span><span class="hs-comment">-- In that case we don't need to extend the substitution</span><span>
</span><span id="line-997"></span><span>        </span><span class="hs-comment">-- to map old to new.  But instead we must zap any</span><span>
</span><span id="line-998"></span><span>        </span><span class="hs-comment">-- current substitution for the variable. For example:</span><span>
</span><span id="line-999"></span><span>        </span><span class="hs-comment">--      (\x.e) with id_subst = [x |-&gt; e']</span><span>
</span><span id="line-1000"></span><span>        </span><span class="hs-comment">-- Here we must simply zap the substitution for x</span><span>
</span><span id="line-1001"></span><span>
</span><span id="line-1002"></span><span>    </span><span id="local-6989586621680854670"><span class="annot"><span class="annottext">new_var :: TyCoVar
</span><a href="#local-6989586621680854670"><span class="hs-identifier hs-var hs-var">new_var</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680854665"><span class="hs-identifier hs-var">no_kind_change</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TyCoVar -&gt; TyCoVar
</span><a href="GHC.Types.Var.Env.html#uniqAway"><span class="hs-identifier hs-var">uniqAway</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680854675"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854672"><span class="hs-identifier hs-var">old_var</span></a></span><span>
</span><span id="line-1003"></span><span>            </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TyCoVar -&gt; TyCoVar
</span><a href="GHC.Types.Var.Env.html#uniqAway"><span class="hs-identifier hs-var">uniqAway</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680854675"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">(TyCoVar -&gt; TyCoVar) -&gt; TyCoVar -&gt; TyCoVar
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1004"></span><span>                          </span><span class="annot"><span class="annottext">TyCoVar -&gt; Type -&gt; TyCoVar
</span><a href="GHC.Types.Var.html#setTyVarKind"><span class="hs-identifier hs-var">setTyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854672"><span class="hs-identifier hs-var">old_var</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst -&gt; Type -&gt; Type
</span><a href="#local-6989586621680854677"><span class="hs-identifier hs-var">subst_fn</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854676"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854666"><span class="hs-identifier hs-var">old_ki</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1005"></span><span>        </span><span class="hs-comment">-- The uniqAway part makes sure the new variable is not already in scope</span><span>
</span><span id="line-1006"></span><span>
</span><span id="line-1007"></span><span class="hs-comment">-- | Substitute a covar in a binding position, returning an</span><span>
</span><span id="line-1008"></span><span class="hs-comment">-- extended subst and a new covar.</span><span>
</span><span id="line-1009"></span><span class="hs-comment">-- Use the supplied function to substitute in the kind</span><span>
</span><span id="line-1010"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substCoVarBndrUsing"><span class="hs-identifier hs-type">substCoVarBndrUsing</span></a></span><span>
</span><span id="line-1011"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1012"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#CoVar"><span class="hs-identifier hs-type">CoVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#CoVar"><span class="hs-identifier hs-type">CoVar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1013"></span><span id="substCoVarBndrUsing"><span class="annot"><span class="annottext">substCoVarBndrUsing :: (TCvSubst -&gt; Type -&gt; Type)
-&gt; TCvSubst -&gt; TyCoVar -&gt; (TCvSubst, TyCoVar)
</span><a href="GHC.Core.TyCo.Subst.html#substCoVarBndrUsing"><span class="hs-identifier hs-var hs-var">substCoVarBndrUsing</span></a></span></span><span> </span><span id="local-6989586621680854662"><span class="annot"><span class="annottext">TCvSubst -&gt; Type -&gt; Type
</span><a href="#local-6989586621680854662"><span class="hs-identifier hs-var">subst_fn</span></a></span></span><span> </span><span id="local-6989586621680854661"><span class="annot"><span class="annottext">subst :: TCvSubst
</span><a href="#local-6989586621680854661"><span class="hs-identifier hs-var">subst</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span id="local-6989586621680854660"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680854660"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680854659"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854659"><span class="hs-identifier hs-var">tenv</span></a></span></span><span> </span><span id="local-6989586621680854658"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680854658"><span class="hs-identifier hs-var">cenv</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680854657"><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854657"><span class="hs-identifier hs-var">old_var</span></a></span></span><span>
</span><span id="line-1014"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isCoVar</span><span> </span><span class="hs-identifier">old_var</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-1015"></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-var">TCvSubst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680854660"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TyCoVar -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#extendInScopeSet"><span class="hs-operator hs-var">`extendInScopeSet`</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854656"><span class="hs-identifier hs-var">new_var</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854659"><span class="hs-identifier hs-var">tenv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680854655"><span class="hs-identifier hs-var">new_cenv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854656"><span class="hs-identifier hs-var">new_var</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1016"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1017"></span><span>    </span><span id="local-6989586621680854654"><span class="annot"><span class="annottext">new_co :: Coercion
</span><a href="#local-6989586621680854654"><span class="hs-identifier hs-var hs-var">new_co</span></a></span></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCoVar -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkCoVarCo"><span class="hs-identifier hs-var">mkCoVarCo</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854656"><span class="hs-identifier hs-var">new_var</span></a></span><span>
</span><span id="line-1018"></span><span>    </span><span id="local-6989586621680854653"><span class="annot"><span class="annottext">no_kind_change :: Bool
</span><a href="#local-6989586621680854653"><span class="hs-identifier hs-var hs-var">no_kind_change</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; Bool
</span><a href="GHC.Core.TyCo.FVs.html#noFreeVarsOfTypes"><span class="hs-identifier hs-var">noFreeVarsOfTypes</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854651"><span class="hs-identifier hs-var">t1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854650"><span class="hs-identifier hs-var">t2</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1019"></span><span>    </span><span id="local-6989586621680854648"><span class="annot"><span class="annottext">no_change :: Bool
</span><a href="#local-6989586621680854648"><span class="hs-identifier hs-var hs-var">no_change</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854656"><span class="hs-identifier hs-var">new_var</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar -&gt; TyCoVar -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854657"><span class="hs-identifier hs-var">old_var</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680854653"><span class="hs-identifier hs-var">no_kind_change</span></a></span><span>
</span><span id="line-1020"></span><span>
</span><span id="line-1021"></span><span>    </span><span id="local-6989586621680854655"><span class="annot"><span class="annottext">new_cenv :: CvSubstEnv
</span><a href="#local-6989586621680854655"><span class="hs-identifier hs-var hs-var">new_cenv</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680854648"><span class="hs-identifier hs-var">no_change</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv -&gt; TyCoVar -&gt; CvSubstEnv
forall a. VarEnv a -&gt; TyCoVar -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#delVarEnv"><span class="hs-identifier hs-var">delVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680854658"><span class="hs-identifier hs-var">cenv</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854657"><span class="hs-identifier hs-var">old_var</span></a></span><span>
</span><span id="line-1022"></span><span>             </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv -&gt; TyCoVar -&gt; Coercion -&gt; CvSubstEnv
forall a. VarEnv a -&gt; TyCoVar -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnv"><span class="hs-identifier hs-var">extendVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680854658"><span class="hs-identifier hs-var">cenv</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854657"><span class="hs-identifier hs-var">old_var</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854654"><span class="hs-identifier hs-var">new_co</span></a></span><span>
</span><span id="line-1023"></span><span>
</span><span id="line-1024"></span><span>    </span><span id="local-6989586621680854656"><span class="annot"><span class="annottext">new_var :: TyCoVar
</span><a href="#local-6989586621680854656"><span class="hs-identifier hs-var hs-var">new_var</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TyCoVar -&gt; TyCoVar
</span><a href="GHC.Types.Var.Env.html#uniqAway"><span class="hs-identifier hs-var">uniqAway</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680854660"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854647"><span class="hs-identifier hs-var">subst_old_var</span></a></span><span>
</span><span id="line-1025"></span><span>    </span><span id="local-6989586621680854647"><span class="annot"><span class="annottext">subst_old_var :: TyCoVar
</span><a href="#local-6989586621680854647"><span class="hs-identifier hs-var hs-var">subst_old_var</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Type -&gt; TyCoVar
</span><a href="GHC.Types.Var.html#mkCoVar"><span class="hs-identifier hs-var">mkCoVar</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCoVar -&gt; Name
</span><a href="GHC.Types.Var.html#varName"><span class="hs-identifier hs-var hs-var">varName</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854657"><span class="hs-identifier hs-var">old_var</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854646"><span class="hs-identifier hs-var">new_var_type</span></a></span><span>
</span><span id="line-1026"></span><span>
</span><span id="line-1027"></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680854651"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854651"><span class="hs-identifier hs-var">t1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680854650"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854650"><span class="hs-identifier hs-var">t2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680854644"><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621680854644"><span class="hs-keyword hs-var">role</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; TyCoVar -&gt; (Type, Type, Type, Type, Role)
TyCoVar -&gt; (Type, Type, Type, Type, Role)
</span><a href="GHC.Core.Coercion.html#coVarKindsTypesRole"><span class="hs-identifier hs-var">coVarKindsTypesRole</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854657"><span class="hs-identifier hs-var">old_var</span></a></span><span>
</span><span id="line-1028"></span><span>    </span><span id="local-6989586621680854643"><span class="annot"><span class="annottext">t1' :: Type
</span><a href="#local-6989586621680854643"><span class="hs-identifier hs-var hs-var">t1'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; Type -&gt; Type
</span><a href="#local-6989586621680854662"><span class="hs-identifier hs-var">subst_fn</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854661"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854651"><span class="hs-identifier hs-var">t1</span></a></span><span>
</span><span id="line-1029"></span><span>    </span><span id="local-6989586621680854642"><span class="annot"><span class="annottext">t2' :: Type
</span><a href="#local-6989586621680854642"><span class="hs-identifier hs-var hs-var">t2'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; Type -&gt; Type
</span><a href="#local-6989586621680854662"><span class="hs-identifier hs-var">subst_fn</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854661"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854650"><span class="hs-identifier hs-var">t2</span></a></span><span>
</span><span id="line-1030"></span><span>    </span><span id="local-6989586621680854646"><span class="annot"><span class="annottext">new_var_type :: Type
</span><a href="#local-6989586621680854646"><span class="hs-identifier hs-var hs-var">new_var_type</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Role -&gt; Type -&gt; Type -&gt; Type
</span><a href="GHC.Core.Coercion.html#mkCoercionType"><span class="hs-identifier hs-var">mkCoercionType</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621680854644"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854643"><span class="hs-identifier hs-var">t1'</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854642"><span class="hs-identifier hs-var">t2'</span></a></span><span>
</span><span id="line-1031"></span><span>                  </span><span class="hs-comment">-- It's important to do the substitution for coercions,</span><span>
</span><span id="line-1032"></span><span>                  </span><span class="hs-comment">-- because they can have free type variables</span><span>
</span><span id="line-1033"></span><span>
</span><span id="line-1034"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#cloneTyVarBndr"><span class="hs-identifier hs-type">cloneTyVarBndr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Unique.html#Unique"><span class="hs-identifier hs-type">Unique</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1035"></span><span id="cloneTyVarBndr"><span class="annot"><span class="annottext">cloneTyVarBndr :: TCvSubst -&gt; TyCoVar -&gt; Unique -&gt; (TCvSubst, TyCoVar)
</span><a href="GHC.Core.TyCo.Subst.html#cloneTyVarBndr"><span class="hs-identifier hs-var hs-var">cloneTyVarBndr</span></a></span></span><span> </span><span id="local-6989586621680854641"><span class="annot"><span class="annottext">subst :: TCvSubst
</span><a href="#local-6989586621680854641"><span class="hs-identifier hs-var">subst</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span id="local-6989586621680854640"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680854640"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680854639"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854639"><span class="hs-identifier hs-var">tv_env</span></a></span></span><span> </span><span id="local-6989586621680854638"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680854638"><span class="hs-identifier hs-var">cv_env</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680854637"><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854637"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span id="local-6989586621680854636"><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621680854636"><span class="hs-identifier hs-var">uniq</span></a></span></span><span>
</span><span id="line-1036"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT2</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isTyVar</span><span> </span><span class="hs-identifier">tv</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">tv</span><span> </span><span class="hs-special">)</span><span>   </span><span class="hs-comment">-- I think it's only called on TyVars</span><span>
</span><span id="line-1037"></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-var">TCvSubst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet -&gt; TyCoVar -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#extendInScopeSet"><span class="hs-identifier hs-var">extendInScopeSet</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680854640"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854635"><span class="hs-identifier hs-var">tv'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1038"></span><span>              </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TvSubstEnv -&gt; TyCoVar -&gt; Type -&gt; TvSubstEnv
forall a. VarEnv a -&gt; TyCoVar -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnv"><span class="hs-identifier hs-var">extendVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854639"><span class="hs-identifier hs-var">tv_env</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854637"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCoVar -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTy"><span class="hs-identifier hs-var">mkTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854635"><span class="hs-identifier hs-var">tv'</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680854638"><span class="hs-identifier hs-var">cv_env</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854635"><span class="hs-identifier hs-var">tv'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1039"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1040"></span><span>    </span><span id="local-6989586621680854634"><span class="annot"><span class="annottext">old_ki :: Type
</span><a href="#local-6989586621680854634"><span class="hs-identifier hs-var hs-var">old_ki</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCoVar -&gt; Type
</span><a href="GHC.Types.Var.html#tyVarKind"><span class="hs-identifier hs-var">tyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854637"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-1041"></span><span>    </span><span id="local-6989586621680854633"><span class="annot"><span class="annottext">no_kind_change :: Bool
</span><a href="#local-6989586621680854633"><span class="hs-identifier hs-var hs-var">no_kind_change</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Bool
</span><a href="GHC.Core.TyCo.FVs.html#noFreeVarsOfType"><span class="hs-identifier hs-var">noFreeVarsOfType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854634"><span class="hs-identifier hs-var">old_ki</span></a></span><span> </span><span class="hs-comment">-- verify that kind is closed</span><span>
</span><span id="line-1042"></span><span>
</span><span id="line-1043"></span><span>    </span><span id="local-6989586621680854630"><span class="annot"><span class="annottext">tv1 :: TyCoVar
</span><a href="#local-6989586621680854630"><span class="hs-identifier hs-var hs-var">tv1</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680854633"><span class="hs-identifier hs-var">no_kind_change</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854637"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-1044"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCoVar -&gt; Type -&gt; TyCoVar
</span><a href="GHC.Types.Var.html#setTyVarKind"><span class="hs-identifier hs-var">setTyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854637"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; Type -&gt; Type
TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTy"><span class="hs-identifier hs-var">substTy</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854641"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854634"><span class="hs-identifier hs-var">old_ki</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1045"></span><span>
</span><span id="line-1046"></span><span>    </span><span id="local-6989586621680854635"><span class="annot"><span class="annottext">tv' :: TyCoVar
</span><a href="#local-6989586621680854635"><span class="hs-identifier hs-var hs-var">tv'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCoVar -&gt; Unique -&gt; TyCoVar
</span><a href="GHC.Types.Var.html#setVarUnique"><span class="hs-identifier hs-var">setVarUnique</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854630"><span class="hs-identifier hs-var">tv1</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621680854636"><span class="hs-identifier hs-var">uniq</span></a></span><span>
</span><span id="line-1047"></span><span>
</span><span id="line-1048"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#cloneTyVarBndrs"><span class="hs-identifier hs-type">cloneTyVarBndrs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Supply.html#UniqSupply"><span class="hs-identifier hs-type">UniqSupply</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1049"></span><span id="cloneTyVarBndrs"><span class="annot"><span class="annottext">cloneTyVarBndrs :: TCvSubst -&gt; [TyCoVar] -&gt; UniqSupply -&gt; (TCvSubst, [TyCoVar])
</span><a href="GHC.Core.TyCo.Subst.html#cloneTyVarBndrs"><span class="hs-identifier hs-var hs-var">cloneTyVarBndrs</span></a></span></span><span> </span><span id="local-6989586621680854628"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854628"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>     </span><span id="local-6989586621680854627"><span class="annot"><span class="annottext">UniqSupply
</span><a href="#local-6989586621680854627"><span class="hs-identifier hs-var">_usupply</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854628"><span class="hs-identifier hs-var">subst</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1050"></span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#cloneTyVarBndrs"><span class="hs-identifier hs-var">cloneTyVarBndrs</span></a></span><span> </span><span id="local-6989586621680854626"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854626"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680854625"><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854625"><span class="hs-identifier hs-var">t</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680854624"><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680854624"><span class="hs-identifier hs-var">ts</span></a></span></span><span class="hs-special">)</span><span>  </span><span id="local-6989586621680854623"><span class="annot"><span class="annottext">UniqSupply
</span><a href="#local-6989586621680854623"><span class="hs-identifier hs-var">usupply</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854622"><span class="hs-identifier hs-var">subst''</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854621"><span class="hs-identifier hs-var">tv</span></a></span><span class="annot"><span class="annottext">TyCoVar -&gt; [TyCoVar] -&gt; [TyCoVar]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680854620"><span class="hs-identifier hs-var">tvs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1051"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1052"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680854619"><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621680854619"><span class="hs-identifier hs-var">uniq</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680854618"><span class="annot"><span class="annottext">UniqSupply
</span><a href="#local-6989586621680854618"><span class="hs-identifier hs-var">usupply'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UniqSupply -&gt; (Unique, UniqSupply)
</span><a href="GHC.Types.Unique.Supply.html#takeUniqFromSupply"><span class="hs-identifier hs-var">takeUniqFromSupply</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSupply
</span><a href="#local-6989586621680854623"><span class="hs-identifier hs-var">usupply</span></a></span><span>
</span><span id="line-1053"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680854616"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854616"><span class="hs-identifier hs-var">subst'</span></a></span></span><span> </span><span class="hs-special">,</span><span> </span><span id="local-6989586621680854621"><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854621"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; TyCoVar -&gt; Unique -&gt; (TCvSubst, TyCoVar)
</span><a href="GHC.Core.TyCo.Subst.html#cloneTyVarBndr"><span class="hs-identifier hs-var">cloneTyVarBndr</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854626"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621680854625"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621680854619"><span class="hs-identifier hs-var">uniq</span></a></span><span>
</span><span id="line-1054"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680854622"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854622"><span class="hs-identifier hs-var">subst''</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680854620"><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680854620"><span class="hs-identifier hs-var">tvs</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; [TyCoVar] -&gt; UniqSupply -&gt; (TCvSubst, [TyCoVar])
</span><a href="GHC.Core.TyCo.Subst.html#cloneTyVarBndrs"><span class="hs-identifier hs-var">cloneTyVarBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854616"><span class="hs-identifier hs-var">subst'</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621680854624"><span class="hs-identifier hs-var">ts</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSupply
</span><a href="#local-6989586621680854618"><span class="hs-identifier hs-var">usupply'</span></a></span><span>
</span><span id="line-1055"></span></pre></body></html>